我想将一个zip文件从外部服务器复制到脚本运行的目录中。
例如:
$thezipfile = "http://www.yxz.com/user/login/userid/1234/password/1234/page/L2V4cG9ydC9kb3dubG9hZC90L01RPT0vYy9NZz09Lw=";
这不起作用(下载.php):
$save = file_put_contents('newfile.zip',$thezipfile);
之后,我的服务器上有一个名为"newfile.zip"的文件,但是。。。它是空的!??
您没有任何要放入新文件的文件内容。
在file_put_contents()
之前需要先file_get_contents($thezipfile)
在保存之前,您需要实际读取外部文件。将第二行更改为
file_put_contents('newfile.zip',file_get_contents($thezipfile));