Jump to content


Photo

save img


  • Please log in to reply
7 replies to this topic

#1 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 08 July 2006 - 11:39 PM

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?


#2 ShiVer

ShiVer
  • Members
  • PipPip
  • Member
  • 14 posts
  • LocationJoMo

Posted 09 July 2006 - 12:55 AM

Your gonna want to rephrase that.
Don't quite understand.

#3 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 09 July 2006 - 12:57 AM

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



#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 09 July 2006 - 06:09 AM

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 ???

#5 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 09 July 2006 - 11:17 AM

I don't want to force it on the users disk, I want to download it to my disk with the script!


#6 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 09 July 2006 - 11:22 AM

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);

?>
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#7 AV1611

AV1611
  • Members
  • PipPipPip
  • Advanced Member
  • 997 posts

Posted 09 July 2006 - 11:50 AM

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


#8 Koobi

Koobi
  • Staff Alumni
  • Advanced Member
  • 419 posts
  • LocationColombo, Sri Lanka | South Asia

Posted 09 July 2006 - 12:12 PM

have a look at this post
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:
$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';
}


i've split the posts after this into another thread:
http://www.phpfreaks...58.new.html#new




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users