Submit]."/> Submit].">

Home  >  Article  >  Web Front-end  >  How does jquery determine whether the uploaded file with input type="file" is empty?

How does jquery determine whether the uploaded file with input type="file" is empty?

coldplay.xixi
coldplay.xixiOriginal
2021-01-06 15:55:224653browse

Jquery method to determine whether the uploaded file with input type="file" is empty: use the html upload button, the code is [094b73ef6aeaa330eabda73d69a3c65fSubmit120d611986108da972f06c8ab0c8bab5].

How does jquery determine whether the uploaded file with input type="file" is empty?

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 = $(&#39;#reportXML&#39;).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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn