Can I use php to hide the real location of my images? I'd like my source to look something like: <img src="myphpscript.php?img=345" /> And have myphpscript.php grab the image from the real location e.g /folder/pix/345.jpg
Dude, you asked a question and i answered it, the question was "Can I use php to hide the real location of my images?" Did you want something else? If you wanted the code, then you should have said so... You should formulate your questions better, before insulting people trying to help you and demanding "intelligent answer". Ask a dumb question and the answer will be the same.
I don't want to get involved in an argument. If it wasn't obvious that I'd like some help with what I'm trying to do, then I apologize. How's this then... "Any idea how to do it?" EDIT : Actually, forget it. I found out how to do it.
Hi Kerosene, no problem, apology accepted, sorry if i offended you. I was actually writing the code and then saw you already solved it (I saw your code too, before you edited it ). Here just few suggestions, for securing the script better: 1) If images are only numbers, then do intval($_GET['img']). 2) Check the passed parameter for file existance before you output it. In that case you could output an "blank.jpg", or "nohacking.jpg", etc, which is better than generating a "broken" image in browser or outputing the error which will give the path of your images folder away. There is more to it, but this should be enough for the moment... Take care
Can I ask he purpose of that hiding ? The easiest/fastest solution is with Apache "mod rewite" module as tushardhoot1 said. With this method you don't need a .php file, only a couple of lines on your .htaccess file: Example RewriteEngine on RewriteRule ^inexistentPhpScript.php?img=(.*)&f=(.*)$ /folder/$2/$1.jpg [L] Code (markup): But if you want to limit the amount of images served per IP, or another task .... then you'll need to code by yourself.
I'm trying to hide ebay auction pics from Google ... 'nuff said I tried the htaccess method, and as much as I like the simplicity of it - I ran a few tests and for some reason the php method actually turned out to be faster.