2016-11-05 116 views
2

我知道有很多問題要求如何做到這一點,但沒有一個似乎涵蓋了我所追求的。php從url中獲取圖像並保存

參見網址:https://nz.tradevine.com/BlobStorage/GetFullPhoto?photoID=3591090673176038018&organisationID=3468490059683634443

我怎樣才能下載此圖片,並保存爲plug.jpg?

我認爲這可能與其他人不同,因爲它沒有例如在URL末尾的.jpg?無論如何,我無法得到它下載。

+0

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

回答

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); 

?> 

希望這將幫助!

+0

感謝第一個工程 –