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 ? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/ 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? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528762 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); ?> Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528764 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 ? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528784 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 Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528789 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 ? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528802 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 ! Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528805 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. Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-528838 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. Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-529004 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 ? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-529021 Share on other sites More sharing options...
harishkumar09 Posted April 29, 2008 Author Share Posted April 29, 2008 Hello , is nobody there ? Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-529606 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. Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-530034 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 ! Link to comment https://forums.phpfreaks.com/topic/103229-how-to-use-php-to-output-an-image-to-the-browser/#findComment-530052 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.