To limit the file size of a Webflow file upload field to less than 10MB using custom JavaScript or jQuery, you can add custom code to your project. Webflow does not currently support this feature out of the box, so custom JavaScript is necessary.
// JavaScript to limit file upload size to 10MB
document.addEventListener("DOMContentLoaded", function () {
const fileInput = document.querySelector('input[type="file"]');
if (fileInput) {
fileInput.addEventListener("change", function () {
const files = this.files;
for (let i = 0; i < files.length; i++) {
if (files[i].size > 10 * 1024 * 1024) { // 10MB in bytes
alert("File size must be less than 10MB");
this.value = ""; // Reset the file input
}
}
});
}
});
<script> tag before adding it to your Webflow settings.
To limit the file upload size to less than 10MB in Webflow, add custom JavaScript code to your project's "Footer Code" section. This will trigger an alert if a file larger than 10MB is uploaded and reset the input field. Publish your project to apply the changes.