Forum Moderators: coopster

Message Too Old, No Replies

Getting PHP to load up images

         

ahmedtheking

11:18 pm on Jan 4, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm storing images on a separate drive than that that has PHP running on it. PHP (the group www) has permission on that drive to read files and so on, how can I get PHP to load that image into a web browser? Even better, how can I get PHPThumb to interact and use that image?

eelixduppy

4:37 am on Jan 5, 2007 (gmt 0)



If it has the proper permissions then there should be no problem with getting the images.


load that image into a web browser

I'm not quite sure what you mean by this. Do you mean

"display the image in the browser"
, or do you mean something different? Perhaps the Image Functions [us3.php.net] will help you? More specifically imagejpeg [us3.php.net] and its brother functions.

alfaguru

5:54 pm on Jan 5, 2007 (gmt 0)

10+ Year Member



Before an image can be accessed in a browser it has to be served by the web server. There are two ways you could approach this:

1) Easy. Configure your web server so the directory where the image is placed is aliased (assigned to a relative URL). Eg, the directory "/var/stuff/morestuff/images" mightbe aliased to "/myimages". The HTML for your page might then include something like <IMG SRC="/myimages/image1.jpg">.
2) Harder (and a bit slower). Have a PHP script serve the images itself. You'd need to do something along the lines of having the request rewritten so "image1.jpg" actually causes the execution of script "image.php?img=image1.jpg". The script would have to read the file, set the required HTTP headers then echo the content of the file. This might be worthwhile if you want to process the file on the way (resize it, say).