Jump to content


image crud need to add validation for fixed size image upload e.g. 600 x 800 only

image-crud validation

  • Please log in to reply
2 replies to this topic

#1 sr@123

sr@123

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 28 May 2015 - 09:51 AM

Hello,

 

i am trying to add fixed image validation in image crud class but not succeded in it. tryed below code but not worked. image not uploaded but  database entry done. any help appreciated.

 

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'];
        }

 

}



#2 jacobaugustine

jacobaugustine

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 07 October 2015 - 08:30 AM

Change this one

if($width != 600 || $height != 800){

return 'maxFileSize';

}
to

if($width > 600 || $height > 800){

return 'maxFileSize';

}



#3 Martin Lobato

Martin Lobato

    Member

  • Members
  • PipPip
  • 14 posts

Posted 25 November 2016 - 07:28 PM

I need to hardocde the image name, the name must be the SKU or produc name that I 've already got from DDBB. The only thing the image crud must do is to add at the end of the file name (and ddbb) the uniqid to avoid duplicates names. 

 

I already add setters, getters and protected variable $hardcode_file_name, but reading the library got a lot of problems due to my lack of expertice, could schedule this tool for the next version?

 

Or maybe someone can get me the correct code? 

 

Thanks to all !







Also tagged with one or more of these keywords: image-crud, validation

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users