Table of Contents

How to Limit an Uploaded File’s Size

Danielle Kellogg Updated by Danielle Kellogg

Scenario

You’ve got a form where users can upload files from their computers or smartphones. But you’ve noticed that many of the uploaded files are huge and taking up a lot of storage space. It would be great if you could limit the size of the files users can upload.

For example, we have a job portal where applicants can apply for jobs and upload their resumes. However, we want to prevent them from uploading resume files that take up too much space. So we want to limit them to files that are no bigger than 20MB:

Jenny Martin tried to upload a file that was larger than 20MB. Instead of the form submitting, she received a message letting her know that she needs to upload a smaller file.

This can work for both File and Image fields.

Requirements

If this your first time creating an app, you'll need to know some basics about adding objects, fields, pages, and views. You can start by reading our Builder Basics section

Other good resources can be found in our designing the database and building pages sections of the knowledge base.

Steps

Select the Object with the File Field

In the Schema section of the Builder, select the object that contains the file field whose size you want to limit. If the file field doesn’t already exist, create a new one.

Open the Field Editor

Click on the more options icon (the "..." icon) and click on the settings to open the editor. Then go to the Validation Rules section.

Add the Validation Rule

Check the “Add field validation rules” box:

For the When part of the rule, select the file field and then the “size is greater than” option. Once that’s selected, you’ll be able to choose the size limit.

For the Message part of the rule, you can enter the custom message you want the user to see.

Your validation rule is now ready and your users will automatically be prompted if they try to upload those larger files.

You can read more about adding and managing validation rules here.

Notes

It is also possible to resize images upon upload. This setting can be accessed from the settings on the image field in the Schema section of the Builder.

How did we do?

How to Customize the Text on a Submit Button

How to Automatically Capture a User’s Location on a Form

Contact