⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How can i only allow spesific width and height when upload images



Freddy Sidauruk

Freddy Sidauruk
  • profile picture
  • Member

Posted 06 August 2015 - 01:24 AM

Hi all this is my first post,

 

i have been working well in my project all about CRUD but feel bored then looking for another way, but my problem use grocery only when users upload images, i want some setting validations for it, if in php codeignter i use this 

$image_info = getimagesize($_FILES["foto"]["tmp_name"]);      //get size images

$image_width = $image_info[0];                               //get width images

$image_height = $image_info[1];                             //get height images


if (($image_height=='350') and ($image_width=='600'))  
{
    //do uploading
}	
			

the only thing hards allow spesific width=350 and height=600

 

 

Thanks for any respond and some tutorial or links

 

 

Thanks freddy


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 07 August 2015 - 19:58 PM

Well you can try - callback upload - where u can test / check the size of the file being uploaded. If it dose not match your requirements - just dont accept it.. throw error ... else ... accept it and let it in.


Freddy Sidauruk

Freddy Sidauruk
  • profile picture
  • Member

Posted 29 August 2015 - 02:50 AM

can you give example code amit ?


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 29 August 2015 - 17:28 PM

http://www.grocerycrud.com/documentation/options_functions/callback_before_upload

 

here u can get the option to do a callback before upload .. now u can check with this.. or u can check with callback_upload ...

only thing is.. when u do a callback_upload .. u need to look up for the return params / values that it might be returning in case everything was fune to go with..

 

Rest paart.. u can check the image dimension using code like this

 

list($width, $height) = getimagesize($_FILES['myfile']['tmp_name']);

 

or something that suites you and your logic.!

 

Happy GCing :)