从其他服务器php下载文件(Download files from other server php)

编程入门 行业动态 更新时间:2024-10-26 22:28:16
从其他服务器php下载文件(Download files from other server php)

我将文件复制到本地服务器时遇到问题。 我只有最后一个文件,plashka_3.png。

警告:复制( http://rus-yurist.ru/images/plashka_1.png)[function.copy ]:无法打开流:HTTP请求失败!

警告:复制( http://rus-yurist.ru/images/plashka_2.png)[function.copy ]:无法打开流:HTTP请求失败!

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

I have a problem with copying files to local server. I've got only the last file, plashka_3.png.

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!

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

最满意答案

我总是使用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'));

更多推荐

本文发布于:2023-08-06 07:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1445287.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   文件   php   server   Download

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!