Jump to content

Archived

This topic is now archived and is closed to further replies.

aeonsky

Hide image URL/path from user

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!

Share this post


Link to post
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">

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

This script does work, but it seems only for JPG images. I need the script to support multiple image formats, and PNG do not work.

 

Any other ways to hide the image source?

 

Thanks for the help!  :D

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Thanks everyone, I fixed it!

 

I modified Northern Flame's script by using readfile and forwarding the contents to itself, because I can not load the contents into a single file since a lot of people will be using at once (don't want any problems).

 

Share this post


Link to post
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,

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

×
×
  • 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.