我试图在图像crud类中添加固定高度、宽度的图像验证,但没有成功。在下面试过但不起作用。图像未上载,但数据库输入已完成。
class ImageUploadHandler
{
========
private function has_error($uploaded_file, $file, $error) {
if ($uploaded_file && is_uploaded_file($uploaded_file)) {
$file_size = filesize($uploaded_file);
list($width, $height, $type, $attr) = getimagesize($uploaded_file);
if($width != 600 || $height != 800){
return 'maxFileSize';
}
} else {
$file_size = $_SERVER['CONTENT_LENGTH'];
}
}注意:代码工作正常。但是错误应该发送到客户端。我想这不是用图像处理的。
发布于 2015-06-08 09:59:42
我成功地添加了对固定大小图像的验证。(问题是,我在正确的轨道上,但下面的代码起作用了)。
在image_crud.php类的第333行。
list($width, $height) = getimagesize($path);
if($width != $this->max_width || $height != $this->max_height)
{
/* Commented below line */
//$ci->image_moo->load($path)->resize($this->max_width,$this->max_height)->save($path,true);
//and returned false
return false;
}发布于 2015-05-28 10:54:01
我觉得你的代码里有个括号不存在.就在return 'masFileSize'下面
发布于 2015-05-28 10:58:01
换这个
if($width != 600 || $height != 800){
return 'maxFileSize';
}至
if($width > 600 || $height > 800){
return 'maxFileSize';
}https://stackoverflow.com/questions/30504310
复制相似问题