Jump to content


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

Upload images Crud Codeignter

  • Please log in to reply
3 replies to this topic

#1 Freddy Sidauruk

Freddy Sidauruk

    Member

  • Members
  • PipPip
  • 10 posts

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



#2 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 07 August 2015 - 07: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.



#3 Freddy Sidauruk

Freddy Sidauruk

    Member

  • Members
  • PipPip
  • 10 posts

Posted 29 August 2015 - 02:50 AM

can you give example code amit ?



#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts
  • LocationMumbai, India

Posted 29 August 2015 - 05:28 PM

http://www.grocerycr...k_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 :)







Also tagged with one or more of these keywords: Upload images, Crud, Codeignter

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users