Jump to content

Archived

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

AV1611

save img

Recommended Posts

If I have url for image like:

<img scr=123.png
or
<or a href=123.png

how can I save the file to disk automatically?

Share this post


Link to post
Share on other sites
Your gonna want to rephrase that.
Don't quite understand.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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 ???

Share this post


Link to post
Share on other sites
I don't want to force it on the users disk, I want to download it to my disk with the script!

Share this post


Link to post
Share on other sites
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);

?>

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

×

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.