CakePHP-Proffer icon indicating copy to clipboard operation
CakePHP-Proffer copied to clipboard

Inconsistent behavior with large image uploads

Open spacebiscuit opened this issue 6 years ago • 1 comments

When i try to upload 2 files which are each around 4mb my request data is empty when I debug in my add method of my controller. If I use smaller files I don't experience this behaviour.

Sometimes when I try a 4mb file and a smaller file around 1mb I see the related hasmany images database table is saved with the dir field as null, the foreign key of the parent is saved and no files are uploaded.

To try and address this I added some validation rules, to limit the dimensions of any files uploaded. The following validation method fails:

src\Model\Validation\UserProfferRules.php :: dimensions

line 28:

$fileDimensions = getimagesize($value['tmp_name']);

Since my field is multi-file upload - 'listing_images[]' the data is in an array and so it should be:

$fileDimensions = getimagesize($value[0]['tmp_name']);

I guess I could write my own custom validator to handle this.

spacebiscuit avatar Jan 10 '19 20:01 spacebiscuit

Also worth checking your php.ini file upload settings, and perhaps adding a fileSize validation rule?

davidyell avatar Jan 11 '19 09:01 davidyell