2016-07-10 6 views
-1

es eine Möglichkeit, Upload mit bestimmten Breite zu zwingen und Höhe in PHP Upload, habe ich dieses Modulerforderliche Breite und Höhe Bild 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'); 
      } 
     } 

Antwort

0

Verwendung getimagesize es Höhe bieten und Breite

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

Getimagesize() ist PHP pro definierte Funktion. Dies bestimmt die Größe einer gegebenen Bilddatei und gibt die Dimensionen zusammen mit dem Dateityp und einer Höhe/Breite zurück. Für weitere Informationen. http://php.net/manual/en/function.getimagesize.php