How to validate the format of the image in image crud?
- Single Page
Posted 15 January 2013 - 20:28 PM
I use image crud and i want to upload image files (jpg, png, gif). But image crud allows me to upload anything (txt, mpeg...).
How can i get restrictions ?
I try to change the 'accept_file_types' in libraries/image_crud.php => 'accept_file_types' => '/.[gif|jpeg|jpg|png]$/i'
But it doesn't work. And the application/config/image_crud doesn't have a line like :
$config['image_crud_file_upload_allow_file_types'] = 'gif|jpeg|jpg|png';
Thanks for your help and sorry for my english
Posted 16 January 2013 - 17:00 PM
Posted 17 January 2013 - 10:52 AM
Take a loock at class ImageUploadHandler on librarie/image_crud.php (~ line 552)
// The php.ini settings upload_max_filesize and post_max_size
// take precedence over the following max_file_size setting:
'max_file_size' => null,
'min_file_size' => 1,
'accept_file_types' => '/.+$/i',
'max_number_of_files' => null,
Maby it can help you.
Posted 18 January 2013 - 18:11 PM
thank you for your answer!
I try everything but nothing works :
//'accept_file_types' => '/.[gif|jpeg|jpg|png]$/i',
//'accept_file_types' => 'gif|jpeg|jpg|png',
//'accepted_file_types' => '/(\\.|\\/)(gif|jpeg|jpg|png)$/i',
'accept_file_types' => 'png',
I don't know why.
is it works for you ?
Posted 20 January 2013 - 19:34 PM