KiberMath's avatar

File size validation

I have a simple from for let user upload file. Also form has some other text fields

And i want to show to user frendly message if file is too big. For this i create validation rule where I check its size.

But, it works only if file size less then upload_max_filesize. If file size greater, then code execution even does not hit validation. it stops by ValidatePostSize middleware, and show to user woops page. And this is bad case.

I want to redirect user back, with form inputs and show to user nice message even in this case

0 likes
1 reply
tykus's avatar
tykus
Best Answer
Level 104

Just validate the file size on the client side, so that you don't have to wait for it to fail for being too large.

1 like

Please or to participate in this conversation.