Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 将zip文件从外部服务器复制到我的服务器_Php_Html - Fatal编程技术网

Php 将zip文件从外部服务器复制到我的服务器

Php 将zip文件从外部服务器复制到我的服务器,php,html,Php,Html,我想将zip文件从外部服务器复制到脚本运行的目录 例如: $thezipfile = "http://www.yxz.com/user/login/userid/1234/password/1234/page/L2V4cG9ydC9kb3dubG9hZC90L01RPT0vYy9NZz09Lw="; 这不起作用(下载.php): 之后,我的服务器上有一个名为“newfile.zip”的文件,但是…它是空的 您没有任何要放入新文件的文件内容 您需要file\u get\u contents($t

我想将zip文件从外部服务器复制到脚本运行的目录

例如:

$thezipfile = "http://www.yxz.com/user/login/userid/1234/password/1234/page/L2V4cG9ydC9kb3dubG9hZC90L01RPT0vYy9NZz09Lw=";
这不起作用(下载.php):


之后,我的服务器上有一个名为“newfile.zip”的文件,但是…它是空的

您没有任何要放入新文件的文件内容


您需要
file\u get\u contents($thezipfile)
然后才能
file\u put\u contents()

保存之前,您需要实际读取外部文件。把你的第二行改成

file_put_contents('newfile.zip',file_get_contents($thezipfile));

包含URL的字符串只是一个字符串。你从来没有真正下载过任何东西,你只是在传递一个字符串。使用curl或
file\u get\u contents
从URL实际下载数据。这是有效的,但仅当字符串为“www.xyz.com/file.zip”时才有效!它不适用于“”首先,当然没有,因为您在问题中没有提供该信息,我们无法知道,或者如果您尝试过。您需要检查包含该文件的服务器上的日志文件,以了解它为什么不工作,然后,当您转到该页面时,与php请求该页面相同。您可能还需要检查它们是否相同。xyz.com不一定与www.xyz.com相同好的!我无法从供应商处检查服务器上的日志文件。问题是URI,我不知道它如何处理这个地址。地址中的“.ZIP”有效,但“./werjwrHEfjh”无效。问题在于字符串。“www.xyz.com/file.zip”有效,但“www.xyz.com/file/page/L2V4cG9ydC9kb3dubG9hZC90=”无效!
file_put_contents('newfile.zip',file_get_contents($thezipfile));