Limit The Size Of A File Upload Html Input Element

[Solved] Limit The Size Of A File Upload Html Input Element | Php - Code Explorer | yomemimo.com
Question : Limit the size of a file upload (html input element)

Answered by : gorgeous-gannet-dmk7nm6ryyn2

var uploadField = document.getElementById("file");
uploadField.onchange = function() { if(this.files[0].size > 2097152){ alert("File is too big!"); this.value = ""; };
};

Source : https://stackoverflow.com/questions/5697605/limit-the-size-of-a-file-upload-html-input-element | Last Update : Wed, 22 Jun 22

Question : input type file limit size

Answered by : hemel-hasan

// With Jquery
$("#aFile_upload").on("change", function (e) { var count=1; var files = e.currentTarget.files; // puts all files into an array // call them as such; files[0].size will get you the file size of the 0th file for (var x in files) { var filesize = ((files[x].size/1024)/1024).toFixed(4); // MB if (files[x].name != "item" && typeof files[x].name != "undefined" && filesize <= 10) { if (count > 1) { approvedHTML += ", "+files[x].name; } else { approvedHTML += files[x].name; } count++; } } $("#approvedFiles").val(approvedHTML);
});

Source : https://stackoverflow.com/questions/5697605/limit-the-size-of-a-file-upload-html-input-element/17173301#17173301 | Last Update : Fri, 04 Mar 22

Answers related to limit the size of a file upload html input element

Code Explorer Popular Question For Php