I have got an input file upload , need to check which file is uploaded / if no file is selected by the client using jquery.
<input type="file" name="files" id="file1" style="color:White" />
<input type="submit" value="Create" />
The check should trigger when submit is clicked.
See the sample I have created:
http://jsfiddle.net/G7xke/
<form>
<input type="file" name="files" id="file1" style="color:White" />
<input type="submit" value="Create" />
</form>
<button value="check" id="check" name="check" >check</button>
And JavaScript:
$("#check").click(function(){
var fileName = $("#file1").val();
if(fileName.lastIndexOf("png")===fileName.length-3)
alert("OK");
else
alert("Not PNG");
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With