Hello,
I would like to save an image from a website to my hard drive automatically using a php script.? Is this possible. I can upload an image automatically to my server but not sure about the other way around.
Thanks
Dave
Save an image to my hard drive automatically.
Moderator: General Moderators
It's not possible. The best you could do is serve the image using a MIME type of "force download"..
The user should be prompted to save the file.. there's no way around that.
Code: Select all
$file = "image.jpg";
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=\"".basename($file)."\";");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ".@filesize($file));
set_time_limit(0);
@readfile($file) or die("File not found.");- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US