我需要從一些URL下載圖像到我的服務器。然而,我的服務器的配置不允許我這樣做是這樣的:什麼是最簡單的方式下載PHP中的文件
getimagesize($file);
因爲,它產生錯誤:
Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in somefile.php on line 10
因此,有另一種方式,我可以使用,不需要外部庫?
好吧,我的解決方案解決了它從OIS:
$filename = '/tmp/'.md5($file);
$ch = curl_init($file);
$fp = fopen($filename, "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$ext = getimagesize($filename);
讀取錯誤消息... – OIS 2010-04-08 23:43:13
這並不是因爲服務器配置的工作,它是不可能的。此外,您的代碼將產生致命錯誤。 – ariefbayu 2010-04-09 00:10:59