harishkumar09 Posted April 28, 2008 Share Posted April 28, 2008 I have the link of an image stored in a free imagehosting site like photobucket. I want to know how to use php script to have the image rendered by the browser.Can anybody help ? Quote Link to comment Share on other sites More sharing options...
schme16 Posted April 28, 2008 Share Posted April 28, 2008 Rendered how? did you mean like how they have a URL like: http://photosite.com/?image=12345 or did you mean resizing and resampleing? Quote Link to comment Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 <?php $imageLocation="http://www.phpfreaks.com/images/logo_main.jpg";//should be absolute location of the image. header("Content-type: image/jpeg"); echo file_get_contents($imageLocation); ?> Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 28, 2008 Author Share Posted April 28, 2008 Rendered how? did you mean like how they have a URL like: http://photosite.com/?image=12345 or did you mean resizing and resampleing? No resizing and re-sampling. Just like you use echo to send text to the browser , I tried using <img src=""> tags to make image appear in the browser and it didnt work. May be some syntax error I think.How to use <img src=""> in php ? Quote Link to comment Share on other sites More sharing options...
DarkWater Posted April 28, 2008 Share Posted April 28, 2008 ... echo '<img src="http://www.whatever.com/path/to/image" />'; O_O Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 28, 2008 Author Share Posted April 28, 2008 <?php $imageLocation="http://www.phpfreaks.com/images/logo_main.jpg";//should be absolute location of the image. header("Content-type: image/jpeg"); echo file_get_contents($imageLocation); ?> Thanks Shenoy , it worked.So I actually have 200 links to images I photographed at a recent air show in a text file.So if I want it all displayed , I guess just have to read it all from the text file , store it in an array and use the file_get_contents() function to output it.Am I right ? Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 28, 2008 Author Share Posted April 28, 2008 ... echo '<img src="http://www.whatever.com/path/to/image" />'; O_O I didnt understand it , sorry ! Quote Link to comment Share on other sites More sharing options...
Rohan Shenoy Posted April 28, 2008 Share Posted April 28, 2008 @Harish, Ya, you can store the URLs in an array and then iterate the array using foreach() function. But, remember to send the content type headers only once at the starting of the script, else it will generate warnings. Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 28, 2008 Author Share Posted April 28, 2008 @Harish, Ya, you can store the URLs in an array and then iterate the array using foreach() function. But, remember to send the content type headers only once at the starting of the script, else it will generate warnings. Thanks for the information. Can you please point me to a tutorial or thread which deals with outputting images and uses all the commands you mentioned ? Actually I accomplished what I wanted using <img src='"'> using concatenation operators inside a for loop. Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 28, 2008 Author Share Posted April 28, 2008 If you look at the phpBB forum , whenever you include multiple images in a single post , it takes time for all the images to appear , as the post gets completed only when all images are displayed on the browser. But if you include only one image per post , the image is immediately loaded and then the next image is loaded and displayed and so on. In other words , we seem to be able to control the order in which images are downloaded and displayed in the phpBB forum by including just one image or multiple images per post. Now, I would like to have the same effect when I read image links from the aforesaid text file and display it on the browser. I want one image to be displayed at a time. I will be displaying 10 images per page but the browser should not go to the next image until the pervious one has been fully displayed. Can you tell me how to do this ? Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 29, 2008 Author Share Posted April 29, 2008 Hello , is nobody there ? Quote Link to comment Share on other sites More sharing options...
schme16 Posted April 30, 2008 Share Posted April 30, 2008 php is server side, that means it outputs after reading a file, but then has nothing to do with the file. I'd say what your looking for is AJAX related. (javascript at the very least). there may be a way to do it in php, but I've never crossed on sorry. Quote Link to comment Share on other sites More sharing options...
harishkumar09 Posted April 30, 2008 Author Share Posted April 30, 2008 php is server side, that means it outputs after reading a file, but then has nothing to do with the file. I'd say what your looking for is AJAX related. (javascript at the very least). there may be a way to do it in php, but I've never crossed on sorry. Oh thanks a lot Jessi , atleast you responded ! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.