Skip to content

Commit

Permalink
file size limit
Browse files Browse the repository at this point in the history
  • Loading branch information
ShivamJoker committed Aug 20, 2020
1 parent 3a6291b commit e896330
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ dropZone.addEventListener("dragleave", (e) => {

// file input change and uploader
fileInput.addEventListener("change", () => {
if (fileInput.files[0].size > maxAllowedSize) {
showToast("Max file size is 100MB");
fileInput.value = ""; // reset the input
return;
}
uploadFile();
});

Expand Down Expand Up @@ -95,6 +100,7 @@ const uploadFile = () => {
// handle error
xhr.upload.onerror = function () {
showToast(`Error in upload: ${xhr.status}.`);
fileInput.value = ""; // reset the input
};

// listen for response which will give the link
Expand Down

0 comments on commit e896330

Please sign in to comment.