close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

File size upload validation

Thread began 2/26/2021 5:05 am by FPhu61701534 | Last modified 10/31/2022 9:04 am by Ray Borduin | 372 views | 5 replies |

FPhu61701534

File size upload validation

I accidentally tried to upload a 10MB image file. The upload failed.

Question #1: What is the max. upload file size allowed?
Question #2: How to set the max. file size the user is allowed to upload, and if it exceeds, to display a message that the maximum allowable file size is __MB?

Sign in to reply to this post

Ray BorduinWebAssist

You can set the max upload size in your php.ini file on your server.

Sign in to reply to this post
Did this help? Tips are appreciated...

FPhu61701534

Noted about setting the php.ini file. But it is still important to sort out the front-end user experience.
Currently, the form will reset itself if the file exceeds the max upload size. The user will mis-interpret it as a successful form submission.

1. How to validate for max upload size and show an error message?
2. How to prevent a form reset if the submit button is clicked?

Really need your help. Thanks!

Sign in to reply to this post

Ray BorduinWebAssist

You can use server validation with integer validation to validate the value of:
<?php echo((isset($_FILES["uploadFieldName"]))?$_FILES["uploadFieldName"]["size"]:"") ?>

I think if it is over the max size it will have a value of the max size, so just check that the number is less than that (in bytes)

You can use the "Validated Form" bindings to re-populate the form when the validation fails.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jonas

I have the same question and try to do as you write but I can't find "Integer" in server validation. Do you perhaps mean "Number" or "Entry Length"? In that case, this means that I have to choose width and height, which I don't want. I want a maximum file size. It seems to be a fairly common question on this forum - so it would be great if there was a tutorial or guide on how to do it.

Sign in to reply to this post

Ray BorduinWebAssist

You can do number validation on the size, which is the file size. You don't have to do width and height, but you could do those separately as well.

Sign in to reply to this post
Did this help? Tips are appreciated...

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...