从其他服务器php下载文件(Download files from other server php)
我将文件复制到本地服务器时遇到问题。 我只有最后一个文件,plashka_3.png。
$txt="http://rus-yurist.ru/images/plashka_1.png http://rus-yurist.ru/images/plashka_2.png http://rus-yurist.ru/images/plashka_3.png"; $a1=explode("\n",$txt); $a1=array_unique($a1); foreach($a1 as $url) { $ch = curl_init($url); $path_parts = pathinfo($url); $path = 'docs/'.$path_parts['basename']; copy($url, $path); // file_put_contents($path, file_get_contents($url)); /* not works too, only last file }警告:复制( http://rus-yurist.ru/images/plashka_1.png)[function.copy ]:无法打开流:HTTP请求失败!
警告:复制( http://rus-yurist.ru/images/plashka_2.png)[function.copy ]:无法打开流:HTTP请求失败!
I have a problem with copying files to local server. I've got only the last file, plashka_3.png.
$txt="http://rus-yurist.ru/images/plashka_1.png http://rus-yurist.ru/images/plashka_2.png http://rus-yurist.ru/images/plashka_3.png"; $a1=explode("\n",$txt); $a1=array_unique($a1); foreach($a1 as $url) { $ch = curl_init($url); $path_parts = pathinfo($url); $path = 'docs/'.$path_parts['basename']; copy($url, $path); // file_put_contents($path, file_get_contents($url)); /* not works too, only last file }Warning: copy(http://rus-yurist.ru/images/plashka_1.png ) [function.copy]: failed to open stream: HTTP request failed!
Warning: copy(http://rus-yurist.ru/images/plashka_2.png ) [function.copy]: failed to open stream: HTTP request failed!
最满意答案
我总是使用file_put_contents
file_put_contents("Tmpfile.zip", fopen("http://someurl/file.zip", 'r'));I always use file_put_contents
file_put_contents("Tmpfile.zip", fopen("http://someurl/file.zip", 'r'));更多推荐
发布评论