Hi guys,
I have this script under my localhost. I want the script to download an image from a website without undergoing the "save as" dialog box as I have lots of images to download. the problem is that, the images on the page are not a direct link to the image file but rather embedded in a php file (ex. display_image.php?image=image_800.jpg). I've tried several methods but the closest I got was to download the .php file. And even if I rename the files to *.jpg, I got no image displayed.
TIA,
Archie
Download an Image (php generated not a direct image link)
Moderator: General Moderators
Re: Download an Image (php generated not a direct image link)
If the image won't display then there's a bug in the script. We can't help you debug it without seeing the source.
Re: Download an Image (php generated not a direct image link)
the image displays correctly in my browser when I use it like . However, when I download the image using php, I can only download the display_image.php file and even if I replace the extension to a .jpg, i get a blank jpg file.
Thanks,
Archie
Code: Select all
<img src="http://blahblah.com/display_image.php?image=image_800.jpg" />Thanks,
Archie
Re: Download an Image (php generated not a direct image link)
Sounds like you're not passing the request through Apache. The script needs to run in order for you to save the output of it, if you try to save it by accessing it through the file system it won't run, the file system will just open the file. If you're doing, for example, file_get_contents("display_image.php?image=image_800.jpg") try using file_get_contents("http://localhost/path/to/your/code/disp ... ge_800.jpg") instead. Though you will need url_wrappers turned on in php.ini for that to work.