Jump to content

Hide image URL/path from user


aeonsky

Recommended Posts

Hello!

 

I've look around Google for an answer, but I couldn't get anything conclusive...

 

Is the only way to hide the image url/path from user, like this below:

 

<img src="index.php/images/disp.php?image=004

 

Is to use the PHP image functions to recompress it and the display using something like this:

 

ImageJpeg ();

 

Thanks for the time and consideration! You guys are great!

Link to comment
Share on other sites

what i sometimes do is create a page, lets say image.php,

and have the code go like this:

 

<?php

 

include('image.jpg');

 

?>

 

so when the user accesses the page,

it just displays a bunch of code,

but it still works when you do this:

 

<img src="image.php">

 

Wait, how does that supposed to work?

 

I just tried it, I get a bunch of ASCII errors.

 

Thanks again!

Link to comment
Share on other sites

<img src="index.php/images/disp.php?image=004">

 

the 'disp.php' file can fopen a file then fread it and then echo it out.  The file to fopen can even be in a directory that does not allow direct web access to the files.  You'll want to use the php header function  to set the content type header before echoing out the file contents:

 

header("Content-type: image/gif");
echo  file_get_contents("/directory/file4.gif");

 

this method should work for every image type, I have used it for jpg's and gif's.

Link to comment
Share on other sites

i would advise to use this function sparingly as it will take up a lot of resources, especially with larger images. if the client wanted the image you cannot stop him.her from prntscrn'ing, in my view trying to hide the source file is a little pointless.

 

hope this helps,

Link to comment
Share on other sites

  • 1 year later...

In Response to uniflare:

This is true, that the current script has no benefit. However, I dont see it using that much more resources than using your web servers mime handler, you are just transferring the mime handling to a php script.

 

but it can be the base for a more functional script, hit counter, hot-link prevention and so forth.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.