jQuery how to tell if file upload has been selected code example
Example: jQuery how to tell if file upload has been selected
// Using jQuery:
if ($('#upload-input-elem').get(0).files.length === 0) {
console.log("No file selected.");
}
else
{
console.log("File Selected");
}
// Using Pure JavaScript:
if( document.getElementById("upload-input-elem").files.length == 0 ){
console.log("no files selected");
}
else
{
console.log("File Selected");
}
// Happy coding, my homies <3