nginx日志
2017/06/27 14:16:53 [error] 70595#0: *986149 FastCGI sent in stderr: "PHP message: PHP Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverable error: in xxxx.php on line 81
PHP message: PHP Warning: imagecreatefromjpeg(): '/upload/20170627/2017062706165379s1U.jpg' is not a valid JPEG file in xxxx.php on line 81
从日志来看,图片格式错误,不是正确的 JPEG (is not a valid JPEG)
再看看php是怎么判断图片类型的,竟然是通过扩展名,扩展名是能随便改的。

if(strpos(strtolower($filename),'.jpg') !== false){
   $source = imagecreatefromjpeg($filename);     
}
if(strpos(strtolower($filename),'.jpeg') !== false){
   $source = imagecreatefromjpeg($filename);     
}
if(strpos(strtolower($filename),'.gif') !== false){
   $source = imagecreatefromgif($filename);      
}
if(strpos(strtolower($filename),'.png') !== false){
   $source = imagecreatefrompng($filename);      
}
if(strpos(strtolower($filename),'.bmp') !== false){
   $source = imagecreatefromwbmp($filename);     
}

测试下那个图片

print_r(getimagesize('E:\cc.jpg'));

Array
(
    [0] => 750
    [1] => 1000
    [2] => 3
    [3] => width="750" height="1000"
    [bits] => 8
    [mime] => image/png
)

image/png!!!!!!!!!!!!!
*还是 getimagesize 来获取扩展名吧。