Help - Search - Members - Calendar
Full Version: Hide image location
HTMLHelp Forums > Programming > Server-side Scripting
Dag
How I can show the image but not to show it's location using the PHP? It must be possible somehow...
Brian Chandler
QUOTE(Dag @ Nov 4 2006, 07:29 PM) *

How I can show the image but not to show it's location using the PHP? It must be possible somehow...


Well, if the browser is to fetch the image file from a location, it can only do so by telling the server the location it wants to fetch from, and it can't do that unless it knows what the location is.

So the simplest answer to your question (as so often on this board) is "No, you can't"

But I believe the http standard includes some stuff about images embedded as data in an html file. Would that help? What are you _actually_ trying to do? If we knew it might be easier to help.

Sparkyg
Nothing is Impossible (except ski-ing through a revolving door), it is possible to keep your images in a "hidden" folder then use a script to display the image

like

<img src="displaymyimage.php?imgid=myimage">


and php would be something like

<?php
header ("Content-type: image/jpeg");
if (file_exists(hiddenpath.$_GET['imgid'])){
$img_handle = imagecreatefromjpeg(hiddenpath.$_GET['imgid'] ) or die("");
ImageJpeg ($img_handle);
}
?>

Providing there is no patterns for your image names, then this should give them a little bit of protection

cheers

Sparky

Peter1968
Would the above defeat seeing the path of the images in Firefox's Tools --> Page Info --> Media list?
Brian Chandler
QUOTE(Sparkyg @ Nov 5 2006, 11:59 PM) *

Nothing is Impossible (except ski-ing through a revolving door), it is possible to keep your images in a "hidden" folder then use a script to display the image

like

<img src="displaymyimage.php?imgid=myimage">http://forums.htmlhelp.com/index.php?act=Post&CODE=02&f=16&t=929&qpid=3838


and php would be something like

<?php
header ("Content-type: image/jpeg");
if (file_exists(hiddenpath.$_GET['imgid'])){
$img_handle = imagecreatefromjpeg(hiddenpath.$_GET['imgid'] ) or die("");
ImageJpeg ($img_handle);
}
?>

Providing there is no patterns for your image names, then this should give them a little bit of protection


Uh, "protection"? Can you explain what this "protection" is? Instead of the image address being "somewhere/myimage", it's now "displaymyimage.php?imgid=myimage". Well, great. Previously the browser asked for one address and got the image - now it asks for a different address and gets the image. Apart from a bit of work, the only real difference you've made is slightly degrading the image, by opening the jpeg into a bitmap, then recompressing it - which is supremely pointless.

As I said, if we knew what the OP was really trying to do, we might be able to help. I'm meaning sometime to block hot-linking to puzzle images (because the copyright is not mine), by generating one-off ids which I keep in a database, and expire after 24 hours. This should have a useful effect, which is more than I can see the above scheme achieving.

(You don't need to generate a new jpeg; the image script should simply copy the jpeg file to stdout.)

Brian Chandler
QUOTE(Peter1968 @ Nov 6 2006, 04:11 AM) *

Would the above defeat seeing the path of the images in Firefox's Tools --> Page Info --> Media list?


What do you mean by "the path of the images"? Of course you can never know the original path in the server filesystem where the image is. All the browser knows is the URL to fetch the image. If the browser doesn't know this, it rather obviously can't fetch the image. Any proper browser will show you, on request, where it went to get the image. If the website proprietor thinks the "real" image is protected because it's somewhere else, well, uh, duh, my head hurts, Brian.
Peter1968
QUOTE(Brian Chandler @ Nov 6 2006, 06:47 AM) *

What do you mean by "the path of the images"?


Sorry, should've wrote "URL" of images.

rolleyes.gif

Sparkyg
If a person wanted to hide the physical location of an image for whatever reason, then doing via the method above is one way.

I may want to store my images in a folder below the web root or only allow certain users access to certain images (which I have done in many member based sites) , maybe Dag can post his exact requirements and get a more exact answer.

Cheers

Sparky
Sparkyg
BTW Brian, I said "and php would be something like" I was purely demonstrating that a script could output an image wink.gif
Darin McGrew
See also the FAQ entry How do I hide my URL?
Peter1968
The net result is that it obfuscates it, not hides it. Not quite the same thing. If it can be seen in a browser, then it's not hidden.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.