Masteries Posted August 14, 2016 Share Posted August 14, 2016 (edited) I'm trying to generate an error on the contact form if the user has uploaded a file that exceeds 2MB. I added the following line to ContactController.php: else if ($fileAttachment['size'] > 2097152) $this->errors[] = Tools::displayError('File size exceeds limit'); Unfortunately, this did not work (but there was no "Internal 500 SERVER ERROR"). What am I doing wrong here? Edited August 16, 2016 by Masteries (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted August 15, 2016 Share Posted August 15, 2016 did you debug this by displaying or recording what the $fileAttachment['size'] returns? Link to comment Share on other sites More sharing options...
vekia Posted August 15, 2016 Share Posted August 15, 2016 $fileAttachment['size'] by default does not exist there is $file_attachment instead you created $fileAttachment variable and assigned to it array of file details from Tools::fileAttachment('fileUpload') method? Link to comment Share on other sites More sharing options...
Masteries Posted August 15, 2016 Author Share Posted August 15, 2016 (edited) $fileAttachment['size'] by default does not exist there is $file_attachment instead you created $fileAttachment variable and assigned to it array of file details from Tools::fileAttachment('fileUpload') method? Oh I see and yes that's what I did. I see that [name] and [error] exists, which class is responsible for these properties? I was thinking I can perhaps add a property as well. Edited August 15, 2016 by Masteries (see edit history) Link to comment Share on other sites More sharing options...
vekia Posted August 15, 2016 Share Posted August 15, 2016 function: fileAttachment is available in: classes/Tools.php 1 Link to comment Share on other sites More sharing options...
Masteries Posted August 16, 2016 Author Share Posted August 16, 2016 function: fileAttachment is available in: classes/Tools.php Thank you! Solved this by adding the following line in Tools.php (after line 2922): $fileAttachment['size'] = $_FILES[$input]['size']; Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now