AV1611 Posted July 8, 2006 Share Posted July 8, 2006 If I have url for image like:<img scr=123.pngor<or a href=123.pnghow can I save the file to disk automatically? Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/ Share on other sites More sharing options...
ShiVer Posted July 9, 2006 Share Posted July 9, 2006 Your gonna want to rephrase that.Don't quite understand. Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-54989 Share on other sites More sharing options...
AV1611 Posted July 9, 2006 Author Share Posted July 9, 2006 Simple. I want to automatically save to disk .png from a remote script.I can access the .png via <a href=file.png... or <img scr=file.png... Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-54991 Share on other sites More sharing options...
Daniel0 Posted July 9, 2006 Share Posted July 9, 2006 You can't, well you can, that is how you get spyware on your computer I believe. But why would you like to force a file onto the user's disk ??? Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55043 Share on other sites More sharing options...
AV1611 Posted July 9, 2006 Author Share Posted July 9, 2006 I don't want to force it on the users disk, I want to download it to my disk with the script! Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55075 Share on other sites More sharing options...
redarrow Posted July 9, 2006 Share Posted July 9, 2006 copy the code a name the file like download.phpadd a link to a page to force download the file a href="download.php">download file</a<?phpfile="123.jpg";$file = $_REQUEST['file'];header("Pragma: public");header("Expires: 0");header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download");header( "Content-Disposition: attachment; filename=".basename($file));header( "Content-Description: File Transfer");@readfile($file);?> Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55077 Share on other sites More sharing options...
AV1611 Posted July 9, 2006 Author Share Posted July 9, 2006 Will this still give me the prompt to download? I am hoping to do this without manual intervention... there is a library of 50 images I need to d/l every day... Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55078 Share on other sites More sharing options...
Koobi Posted July 9, 2006 Share Posted July 9, 2006 have a look at [url=http://www.phpfreaks.com/forums/index.php/topic,99889.msg393691.html#msg393691]this post[/url]you can use those two functions.suppose your image was at http://www.example.org/image.png and you wanted to save it to /var/www/myImage.png, you would use those two functions like this:[code=php:0]$data = getData('http://www.example.org/image.png');$result = writeData($data, '/var/www/myImage.png');if($result !== false){ echo 'Image was written';}else{ echo 'Image could not be written';}[/code]i've split the posts after this into another thread:http://www.phpfreaks.com/forums/index.php/topic,99958.new.html#new Quote Link to comment https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55083 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.