在網上下了一個圖片裁剪的外掛程式jquery.cropzoom.min.js,功能非常的強大,而且還幫我準備了一個php的動態指令碼,不費多少功夫就搭好了。而且跑起來挺不錯的。裁剪+旋轉圖片,一鍵即可。
一開始沒什麼問題,後來修改時,就出現了一個莫名的錯誤。詳細的描述如下:
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
Warning: getimagesize(http://localhost/cms/uploadfiles/2010/08/24/133934.jpg) [function.getimagesize]: failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in D:/AppServ/www/cms/test/test.php on line 3
Fatal error: Maximum execution time of 30 seconds exceeded in D:/AppServ/www/cms/test/test.php on line 3
××××××××××××××××××××××××××××××××××××××××××××××××××××××××××××
看到這個錯誤,我就想是不是getimagesize需要伺服器配置什麼,因為在家裡是行的,我立刻debug了一下:
<?php $size =getimagesize("http://localhost/cms/uploadfiles/2010/08/24/133934.jpg"); var_dump($size); ?>
結果顯示挺正常的:
X-Powered-By: PHP/5.2.10 ZendServer
Set-Cookie: ZendDebuggerCookie=127.0.0.1%3A10137%3A0||084|77742D65|1003; path=/
Content-type: text/html
array(7) {
[0]=>
int(800)
[1]=>
int(533)
[2]=>
int(2)
[3]=>
string(24) "width="800" height="533""
["bits"]=>
int(8)
["channels"]=>
int(3)
["mime"]=>
string(10) "image/jpeg"
} 然後直接在apache上跑了一下這代碼(web),就出現了同樣的問題了。 這麼看來,應該是跟伺服器相關了。後來懷著揣測的心態,把http://localhost/cms/uploadfiles/2010/08/24/133934.jpg改成了相對位址../../uploadfiles/2010/08/24/133934.jpg 嘿,還真行了。看來它是把圖片當遠程載入了,不知道getimagesize的工作原理,所以也無從猜測。 但是如果是這樣,那php怎麼能直接直接擷取remote photo的大小。。 求解。