0
我正在使用getimagesize()來收集遠程加載的圖像信息。遠程PHP getimagesize()/檢查是否存在
問題是如果遠程服務器在請求上花費太長時間或圖像不存在,並且出現錯誤超時。我能做些什麼來防止這種情況發生,所以如果需要15秒鐘自動加載請求,那麼返回一些返回null $ width,$ height和$ type的代碼?
if($siteImage != "None"){
list($width, $height, $type) = getimagesize($siteImage);
if(!filter_var($siteImage, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED)){
die("fillDiv('checkImage','<font color=\"red\">Image is not valid URL type.</font>');");
}elseif($width != "468" || $height != "60"){
die("fillDiv('checkImage','<font color=\"red\">Incorrect size.</font>');");
}elseif($type != "1" && $type != "2" && $type != "3"){
die("fillDiv('checkImage','<font color=\"red\">Incorrect image type. (.jpg .gif .png) only</font>');");
}else{
print("fillDiv('checkImage','');");
}
}
選項1適用於我。謝謝, 有沒有辦法讓超時時間不會這麼長。加快獲取返回值的速度需要多長時間? – Ajezior
我沒有嘗試過(我總是使用cUrl作爲遠程的東西),但你可以嘗試http://php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout – Robbie