Simple application example of php download file function

WBOY
Release: 2016-07-27 16:56:19
Original
781 people have browsed it
  1. php下载文件函数
  2. set_time_limit(24*60*60);
  3. if (!isset($_POST['submit'])) die ();
  4. $destination_folder = './down/'; // 文件夹保存下载文件。必须以斜杠结尾
  5. $url = $_POST['url'];
  6. $newfname = $destination_folder.basename($url);
  7. $file = fopen($url, "rb");
  8. if ($file) {
  9. $newf = fopen($newfname, "wb");
  10. if ($newf) while (!feof($file)) {
  11. fwrite($newf, fread($file, 1024*8), 1024*8);
  12. }
  13. }
  14. if ($file) {
  15. fclose($file);
  16. }
  17. if ($newf) {
  18. fclose($newf);
  19. }
  20. ?>
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template