首页 > php代码 > php 自动下载远程服务器文件

php 自动下载远程服务器文件

<?php
// maximum execution time in seconds
set_time_limit(24 * 60 * 60);
if (!isset($_POST['submit'])) die();
// folder to save downloaded files to. must end with slash
$destination_folder = 'temp/';
$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);
}


本文地址:http://www.phprm.com/code/7bcfb1949daaad743708996806364539.html

转载随意,但请附上文章地址:-)

标签:none

发表留言