Use jquery. upload. js to Implement Asynchronous upload example code _ jquery-js tutorial

Source: Internet
Author: User
This article mainly introduces the sample code for asynchronous upload using jquery. upload. js. If you need it, you can refer to the following resources to download: upload

1: jsp code:

Import jquery. upload. js and jquery-1.7.2.js

Add the code to call js: Upload

Write at the bottom:

 

2: js Code:

/* File Upload */function doUpload () {// upload method $. upload ({// upload url: window. basePath + '/reply/imageUpload', // file domain name fileName: 'uploadfile', // other form data params :{}, // After the upload is complete, return json, textdataType: 'json', // callback before upload. return true indicates that onSend: function () {return true ;}, onSubmit: function (){}, // callback onComplate: function (data) {if (data. msg) {} else {alert ("An error occurred while uploading the image! ");}}});}

3: Background code:

/*** Upload image to the local server * @ param request * @ param response * @ return */@ RequestMapping (value = "imageUpload") @ ResponseBodypublic Object imageUpload (HttpServletRequest request, httpServletResponse response) {Map
 
  
Map = new HashMap
  
   
(); UploadUtil uploadUtil = new UploadUtil (); try {String url = uploadUtil. excelUpload (request, response); // File Upload} catch (IOException e) {e. printStackTrace ();} return map ;}
  
 
Related Article

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.