Submit]."/> Submit].">
Home >Web Front-end >JS Tutorial >How does jquery determine whether the uploaded file with input type='file' is empty?
Jquery method to determine whether the uploaded file with input type="file" is empty: use the html upload button, the code is [094b73ef6aeaa330eabda73d69a3c65fSubmit120d611986108da972f06c8ab0c8bab5].
The operating environment of this tutorial: windows7 system, jquery3.2.1 version, DELL G3 computer. This method is suitable for all brands of computers.
Recommended: jquery video tutorial
Jquery method to determine whether the uploaded file with input type="file" is empty:
If you want to get the input content of type="file"
, use var file = $("id").val();
It will definitely not work. Here is the code:
html upload button is:
<input type="file" id="reportXML" name="reportXML" title="输入内容" multiple="multiple"> <button type="button" onclick="submitXML()">提交</button>
js code:
function submitXML(){ var fileInput = $('#reportXML').get(0).files[0]; console.info(fileInput); if(fileInput){ $("#reportXMLform").submit(); }else{ alert("请选择上传文件!"); } }
Related free learning recommendations: js video tutorial
The above is the detailed content of How does jquery determine whether the uploaded file with input type='file' is empty?. For more information, please follow other related articles on the PHP Chinese website!