从绝对路径(其他域)下载文件


download file from absolute path (other domain)

可能重复:
在PHP 中下载文件的最佳方式

我被要求下载几个视频,格式如下:

http://website.com/asset/v00/488/618.asx

我找不到路(保存为..是不可能的,所有这些youtube下载服务都说"服务未知"(。我可以用一些php脚本吗?

如果能够调用这样的函数,那就太好了:

function downloadFile($url){
   //prompt download
}

如果文件很大,则必须在将传入数据写入磁盘时使用fopen((读取其内容:

$fp = fopen('http://website.com/asset/v00/488/618.asx', 'r');
$fpl = fopen('local/618.asx', 'w');
while(!feof($fp)){
    fwrite($fpl, fread($fp, 1024));
}
fclose($fp);
fclose($fpl);

否则,如果文件很小,您可以将其文件_get_contents((到内存中,然后使用file_put_contents。。。