Posted By

benphelps on 08/10/08


Tagged

url php remote file download from


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

benphelps
goo
wizard04


Download file from URL


 / Published in: PHP
 

URL: http://phelps.impactwow.com

  1. <?
  2. // DOWNLOAD REMOTE FILE
  3. // this is a-lot more complicated than it looks
  4. // $url is the url of the file, must have fopen wrappers enabled
  5. // $dir is the directory to save the file to relative to the current working directory
  6. // file is saved with the same file name from its source
  7. function getfile($url, $dir){
  8. file_put_contents($dir.substr($url,strrpos($url,'/'),strlen($url)), file_get_contents($url));
  9. }
  10. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: romanos on August 10, 2008

Why don't use copy() function?

You need to login to post a comment.