Submit]."> How does jquery determine whether the uploaded file with input type='file' is empty?-JS Tutorial-php.cn

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

coldplay.xixi
Release: 2023-01-04 09:38:57
Original
4627 people have browsed it

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

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", usevar file = $("id").val();It will definitely not work. Here is the code:

html upload button is:

 
Copy after login

js code:

function submitXML(){ var fileInput = $('#reportXML').get(0).files[0]; console.info(fileInput); if(fileInput){ $("#reportXMLform").submit(); }else{ alert("请选择上传文件!"); } }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!