php下载文件函数的简单应用实例
时间:2021-07-01 10:21:17
帮助过:22人阅读
-
-
-
- php下载文件函数
-
-
-
-
- set_time_limit(24*60*60);
- if (!isset($_POST['submit'])) die ();
- $destination_folder = './down/'; // 文件夹保存下载文件。必须以斜杠结尾
- $url = $_POST['url'];
- $newfname = $destination_folder.basename($url);
- $file = fopen($url, "rb");
- if ($file) {
- $newf = fopen($newfname, "wb");
- if ($newf) while (!feof($file)) {
- fwrite($newf, fread($file, 1024*8), 1024*8);
- }
- }
- if ($file) {
- fclose($file);
- }
- if ($newf) {
- fclose($newf);
- }
- ?>
|