The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Hide image location, PHP only
Dag
post Nov 4 2006, 05:29 AM
Post #1


Member
***

Group: Members
Posts: 89
Joined: 24-October 06
Member No.: 549



How I can show the image but not to show it's location using the PHP? It must be possible somehow...
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 4 2006, 07:32 AM
Post #2


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



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.

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sparkyg
post Nov 5 2006, 09:59 AM
Post #3


Member
***

Group: Members
Posts: 46
Joined: 29-September 06
From: Suffolk UK
Member No.: 270



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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Peter1968
post Nov 5 2006, 02:11 PM
Post #4


Serious Coder
*****

Group: Members
Posts: 448
Joined: 23-September 06
Member No.: 213



Would the above defeat seeing the path of the images in Firefox's Tools --> Page Info --> Media list?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 5 2006, 02:41 PM
Post #5


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



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.)

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Brian Chandler
post Nov 5 2006, 02:47 PM
Post #6


Jocular coder
********

Group: Members
Posts: 2,298
Joined: 31-August 06
Member No.: 43



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Peter1968
post Nov 5 2006, 03:02 PM
Post #7


Serious Coder
*****

Group: Members
Posts: 448
Joined: 23-September 06
Member No.: 213



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

User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sparkyg
post Nov 5 2006, 05:24 PM
Post #8


Member
***

Group: Members
Posts: 46
Joined: 29-September 06
From: Suffolk UK
Member No.: 270



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
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Sparkyg
post Nov 5 2006, 05:30 PM
Post #9


Member
***

Group: Members
Posts: 46
Joined: 29-September 06
From: Suffolk UK
Member No.: 270



BTW Brian, I said "and php would be something like" I was purely demonstrating that a script could output an image wink.gif
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Darin McGrew
post Nov 6 2006, 09:18 AM
Post #10


WDG Member
********

Group: Root Admin
Posts: 8,284
Joined: 4-August 06
From: Mountain View, CA
Member No.: 3



See also the FAQ entry How do I hide my URL?
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Peter1968
post Nov 6 2006, 03:41 PM
Post #11


Serious Coder
*****

Group: Members
Posts: 448
Joined: 23-September 06
Member No.: 213



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 10th December 2018 - 10:20 PM