Created
March 26, 2019 16:05
-
-
Save Neoglyph/fc6c3cd22982ea9033e93c408737a486 to your computer and use it in GitHub Desktop.
Limit file size on file input (basic javascript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var imageStatus = document.getElementById('my-file-input'); | |
// imageStatus = input[type="file"] | |
if (files[0].size > fileMaxSize) { | |
imageStatus.innerText = 'Datoteka ne sme biti večja od 5MB!'; | |
imageUpload.value = ''; | |
var imageUploadClone = imageUpload.cloneNode(true); | |
imageUpload.parentNode.replaceChild(imageUploadClone, imageUpload); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment