Jump to content

[SOLVED] Generate error if $fileAttachment exceeds 2MB


Masteries

Recommended Posts

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 by Masteries (see edit history)
Link to comment
Share on other sites

$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 by Masteries (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...