Welcome Guest, Not a member yet? Register   Sign In
Error message is "You did not select a file to upload" but the actual error is that "the file is too big".
#1

[eluser]searain[/eluser]
Code:
$config['upload_path'] = $path;
        $config['allowed_types'] = 'pdf';
        $config['max_size']    = '8000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768'

I set up the limits for uploading file, the max size is 8000 KB for example, the type is pdf. If I try to upload a jpg file, I would get the right error message, "The filetype you are attempting to upload is not allowed."

But if I try to upload a file that is 10000 KB, I would get "You did not select a file to upload." message, which is misleading.

But actually it is the size problem. I should get the messages like the below

either

$lang['upload_file_exceeds_limit'] = "The uploaded file exceeds the maximum allowed size in your PHP configuration file.";

or

$lang['upload_file_exceeds_form_limit'] = "The uploaded file exceeds the maximum size allowed by the submission form.";

Could anyone help me to get the right error message returned?

Plus, when I upload a size too large file, it took a long time for the response "The filetype you are attempting to upload is not allowed." to be returned.

Any advices on this too?

Thanks!
#2

[eluser]searain[/eluser]
OK, found the reason. If the file size is greater than post_max_size, then the $_FILES will be empty.
http://www.php.net/manual/en/features.fi....php#57193

In this case, CI upload class would generate a misleading error message "You did not select a file to upload".

Is there anyway that we can extend the Upload class to generate the right error message in the case "the file size is greater than post_max_size"?

Could I use the $_SERVER['CONTENT_LENGTH'] to detect this error?

http://www.php.net/manual/en/features.fi....php#73762

Any chances, CI developer can add this error checking into the Upload library?




Theme © iAndrew 2016 - Forum software by © MyBB