A simple php file download function

WBOY
Release: 2016-07-25 08:58:45
Original
860 people have browsed it
  1. php文件下载_bbs.it-home.org
  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. ?>
复制代码

代码比较简单,适合刚刚接触php文件操作的朋友,有利于快速掌握有关php文件下载的知识。



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