PHP保存从URL下载的损坏的图像文件

时间:2017-10-21 19:07:39

标签: php copy fopen file-get-contents file-put-contents

无论我使用哪种功能:

copy("http:" . $imglink, "images/" . substr($imglink, 34));
//or
file_put_contents("images/" . substr($imglink, 34), file_get_contents("http:" . $imglink));
//or
file_put_contents("images/" . $productData['imagefile'], fopen($productData['imagelink'], 'r'));

文件被保存破碎,几乎大4倍。日志中没有错误, 已经检查过我可以通过浏览器手动从远程服务器下载健康的图像。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

发现问题 - 图像文件名包含空格char  EndRace - 在作为参数传递之前编辑