⚠ 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

upload file size



PunkMaster
  • profile picture
  • Member

Posted 01 April 2014 - 10:14 AM

I have been using Codgniter and grocerycrude for some time but i have stumble on one thing that i cant clearly understand why it shouldn't work 

 

My problem is, i want to upload pdf file only and the size must not exceed 5MB specifically for a particular function. And i dont want to set this configuration in the grocerycrude config file, but rather in a callback fuction (call_back_before_upload) something like this 

 

 

function valid_magazine($files_to_upload, $field_info){
        if ($files_to_upload[$field_info->encrypted_field_name]['type'] !='magazines/pdf'){
         return 'Sorry, you can only upload pdf file.';
        }
        elseif($files_to_upload[$field_info->encrypted_field_name]['size'] > '5MB'){
            return 'Sorry, the file size must be under 5MB';
        }
        else
        {
            return true;
       
    }

 

 

 

But the result is different. First it check for only one condition and not for the other one, and the result is not consistency. The way it should work is if i try to upload a word document or a file size it should check for file type first and fire up an error, but instead it gives out the the result of the second condition even though the file is under 5MB
 
Any one with and idea?