要求的宽度和高度的图像的PHP的Prestashop

问题描述:

有一种方法强制上传与PHP上传特定的宽度和高度,我有这个模块要求的宽度和高度的图像的PHP的Prestashop

 if(Configuration::get('SHOW_IMAGES') == 1) { 

      $images = count($_FILES['images']['name']); 
      if ($images <= Configuration::get('MAX_IMAGES')) { 
       for ($i=1; $i<=Configuration::get('MAX_IMAGES'); $i++) { 
        if ($_FILES['images']['name'][$i] != "") { 
         if ((($_FILES['images']['type'][$i] == "image/pjpeg") || 
           ($_FILES['images']['type'][$i] == "image/jpeg") || 
           ($_FILES['images']['type'][$i] == "image/png")) && 
           ($_FILES['images']['size'][$i] < $this->return_bytes(ini_get('post_max_size')))) { 
          $url_images[$i] = $_FILES['images']['tmp_name'][$i]; 
         } 
         else { 
          $this->errors[] = $this->module->l('The image format is incorrect or max size to upload is', 'addproduct').' '.ini_get('post_max_size'); 
         } 
        } 
        else { 
         $this->errors[] = $this->module->l('The image is incorrect or max size to upload is', 'addproduct'); 
        } 
       } 
      } 
      else { 
       $this->errors[] = $this->module->l('The maxim images to upload is', 'addproduct').' '.Configuration::get('MAX_IMAGES'); 
      } 
     } 

使用和getimagesize它将提供高度和宽度

list($width, $height, $type, $attr) = getimagesize($file["tmp_name"]);  
if ($width == $minwidth && $height == $minheight) 
{ 
    echo "success";  
}else 
{ 
    echo "error";    
} 

getimagesize()是php每个定义的函数。这将决定任何给定图像文件的大小,并返回尺寸以及文件类型和高度/宽度。更多信息。 http://php.net/manual/en/function.getimagesize.php