Jump to content

save img


AV1611

Recommended Posts

copy the code a name the file like download.php

add a link to a page to force download the file
a href="download.php">download file</a

<?php

file="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);

?>
Link to comment
https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55077
Share on other sites

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
Link to comment
https://forums.phpfreaks.com/topic/14064-save-img/#findComment-55083
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.