Exception When Uploading Large Files

Hi guys

I’m getting this strange issue when uploading files that are too large.

I have a limit of 5mb for uploads, but when someone tries to upload a larger file, the the following exception is thrown:

finfo_file(): Empty filename or path

This only happens on the production server (lamp stack) but I get the nice flash message in my development environment (MAMP).

I have the following rule in the Document model:

array('document_name', 'file', 'allowEmpty' => false,

                'maxSize' => 1024 * 1024 * 5,

                'mimeTypes' => 'image/jpg, image/jpeg, image/pjpeg, image/png, application/pdf,

                    application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, text/plain',

                'tooLarge' => 'The file was larger than 5MB. Please upload a smaller file.',

                'wrongType' => 'You can only upload files of the type listed on this page.',

                'message' => 'Please select a file to upload.')

and I’m saving the file as follows:

if ($model->validate() && $model->save() {


I don’t understand why it would work fine in MAMP but not on the server.

Any ideas would be greatly appreciated!

check your php.ini (there is file size limit and also POST request body size limit). There can be also similar limit in other places, like suhosin_patch, fcgid (of course if you use them)…

Thanks for getting back. Yes it turns out that the server was updated by a new administrator and the max upload size was set to 5mb. It’s a pity that Yii 1.1 doesn’t deal with this situation so well, but I’ve read that Yii 2.0 has a requirements checker class which sounds promising. Anyway, the problem was solved by increasing the max upload size.

Thanks again.