今天在写封面上传的时候碰到了,开始以为是layui的问题,看了下官方文档,做了个小demo测试没问题。
于是查看了tp的源码,在/thinkphp/library/think/File.php中 有一个图片严格检查。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| if (!$this->checkImg()) { $this->error = 'illegal image files'; return false; }
public function checkImg() { $extension = strtolower(pathinfo($this->getInfo('name'), PATHINFO_EXTENSION));
if (in_array($extension, ['gif', 'jpg', 'jpeg', 'bmp', 'png', 'swf']) && !in_array($this->getImageType($this->filename), [1, 2, 3, 4, 6, 13])) { return false; } return true; }
|
想了想可能是没装exif之类的拓展,于是在装了exif,fileinfo的php拓展之后 一切正常