0

有没有办法将文件直接下载到我的虚拟主机?假设我想从网站下载视频文件并再次将其上传到我的网站。与其将其下载到我的电脑并上传,有没有办法轻松做到这一点?

谢谢!

4

1 回答 1

2

我现在正在使用这个脚本:)

`

if (!isset($_POST['submit'])) die();

// folder to save downloaded files to. must end with slash
$destination_folder = 'downloads/';

$url = $_POST['url'];
$name = $_POST['name'];
$ext = $_POST['extention'];

$newfname = $destination_folder . $name . '.' . $ext;

$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);
}

echo 'File saved as '. $newfname

?>`

于 2012-09-27T02:47:40.413 回答