jquery Plugin ajaxfileupload for Ajax file uploads

Source: Internet
Author: User

jquery Plugin Ajaxfileupload is used to implement the Ajax file upload, the plug-in is very simple to use, and then write a demo demo How to use the Ajaxfileupload plugin for file upload.

1, introduce the Ajaxfileupload plugin related JS

 <  script  type  = "Text/javascript"   src  = "<%=basepath%>resources/js/jquery-1.2.1.js"  ></ script  >  <  script  type  = "Text/javascript"   src  = "<%=basepath%>resources/js/ajaxfileupload.js"  ></ script  >  

Note: The test found that ajaxfileupload to the jquery version is required, in the use of Ajaxfileupload and jquery corresponding to the JS version to be consistent, otherwise it will cause an exception, can be downloaded from the ajaxfileupload official website to avoid version conflicts.

2. Implement the Upload function code

Html

<type= "file"  name= "Business_licence"  ID= " Business_licence "  onchange=" upload_image (' business_licence '); " >

JS Processing

//Upload thumbnail image    functionUpload_image (upfile_name) {varLoadi = layer.load (' File crosses ... ')); $.ajaxfileupload ({URL:' <{site_url (' upload/index ')}>?file_name= ' +upfile_name, Secureuri:false, Fileelementid:upfile_name, DataType:' JSON ', Success:function(data) {layer.close (Loadi)if(Data.state = = ' SUCCESS ') {                    $("#" +upfile_name+ "_pic"). Val (Data.url); } Else{layer.msg (data.state,2,-1); return false;    }            }        }); }

jquery Plugin ajaxfileupload for Ajax file uploads

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.