php从url中获取图像并保存

问题描述:

我知道有很多问题要求如何做到这一点,但没有一个似乎涵盖了我所追求的。php从url中获取图像并保存

参见网址:https://nz.tradevine.com/BlobStorage/GetFullPhoto?photoID=3591090673176038018&organisationID=3468490059683634443

我怎样才能下载此图片,并保存为plug.jpg?

我认为这可能与其他人不同,因为它没有例如在URL末尾的.jpg?无论如何,我无法得到它下载。

+0

http://*.com/questions/724391/saving-image-from-php-url – barudo

您也可以做到这一点下面的代码

<?php 

$file = file_get_contents('https://nz.tradevine.com/BlobStorage/GetFullPhoto?photoID=3591090673176038018&organisationID=3468490059683634443'); 

$myfile = fopen("plug.jpg", "w") or die("Unable to open file!"); 
fwrite($myfile, $file); 
fclose($myfile); 

?> 

希望这将帮助!

+0

感谢第一个工程 –