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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.