PHP编程

php实现将远程文件下载保存到服务器指定文件夹

日期:2015-06-28 00:00:00 来源: IT猫扑网

直接上代码啦..

  1.       
  2. "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">   
  3. "http://www.w3.org/1999/xhtml" lang="zh-cn">   
  4.    
  5. "Content-Type" content="text/html; charset=UTF-8" />   
  6. "Content-Language" content="UTF-8" />   
  7.    
  8. "post">   
  9. "url" size="20" />   
  10. "submit" type="submit" />   
  11.    
  12.    
  13. set_time_limit (24 * 60 * 60);   
  14. if (!isset($_POST['submit'])) die();   
  15. $destination_folder = './downfolde/';   // 文件夹保存下载文件。必须以斜杠结尾   
  16. $url = $_POST['url'];   
  17. $newfname = $destination_folder . basename($url);   
  18. $file = fopen ($url"rb");   
  19. if ($file) {   
  20. $newf = fopen ($newfname"wb");   
  21. if ($newf)   
  22. while(!feof($file)) {   
  23. fwrite($newffread($file, 1024 * 8 ), 1024 * 8 );   
  24. }   
  25. }   
  26. if ($file) {   
  27. fclose($file);   
  28. }   
  29. if ($newf) {   
  30. fclose($newf);   
  31. }   
  32. ?>    

相关文章

相关下载

网友评论

我要评论...
    没有更早的评论了
    取消