php从url获取图像并保存

时间:2016-11-05 11:47:20

标签: php image curl download

我知道有许多问题要求如何做到这一点,但似乎没有任何问题可以涵盖我所追求的目标。

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

如何下​​载此图像并保存为plug.jpg?

我认为这可能与其他人不同,因为它在网址的末尾没有例如.jpg?无论哪种方式,我都无法下载。

1 个答案:

答案 0 :(得分:1)

您也可以使用以下代码

执行此操作
<?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);

?>

希望这会有所帮助!