Client Checking file size using HTML5?
This works. Place it inside an event listener for when the input changes.
if (typeof FileReader !== "undefined") {
var size = document.getElementById('myfile').files[0].size;
// check file size
}
HTML form with multiple file upload fields, how to check max file size client side
You'll need to delegate for objects that are dynamically added.
In your code, use this instead of addressing file1 specifically
$("#files").delegate("input","change",function(){
if(this.files[0].size > 2000000){
alert('File is larger than 2MB. Please choose a smaller file');
this.value = "";
};
});
Size limit for file upload
Nope, there is no size upload limit.
here is the spec and here is a related question on how to check the file size, so that you can add limits if you like.
It's worth pointing out that if you are looking to store the file on the server, you might hit file upload limits/restrictions there. But you should be able to configure them. i.e. php/wordpress default upload limit
Related Topics
Why Can't I Call a Function Named Clear from an Onclick Attribute
Offsetting an HTML Anchor to Adjust For Fixed Header
How to Get the Data-Id Attribute
Make Iframe Automatically Adjust Height According to the Contents Without Using Scrollbar
When to Use Functional Setstate
Do Html5 Custom Data Attributes "Work" in Ie 6
How to Get the Selected Radio Button'S Value
Can One Angularjs Controller Call Another
How to Launch HTML Using Chrome At "--Allow-File-Access-From-Files" Mode
Load and Execution Sequence of a Web Page
Using an HTML Button to Call a JavaScript Function
Why Js Function Name Conflicts With Element Id
How to Get the Body'S Content of an Iframe in JavaScript
How to Retrieve an HTML Element'S Actual Width and Height