A little problem with the process of using the Webuploader plug-in _jquery

Source: Internet
Author: User
Tags rar

This article for everyone to solve the Webuploader upload plug-ins How to customize the parameters of the problem for your reference, the specific content as follows

Approximate schema:

Front End: Html5+ajax

Back end: Java (Struts framework related)

Problems encountered:

Background coder provide me with an interface./file/uploader.do?upfile=?, let me upload the file corresponding to upfile this parameter, the front-end use is Webuploader this upload plug-in, do not know how this thing to customize parameters. After a variety of Google, Baidu, find the following two kinds of solutions:

1, the interface does not need to specify the parameters, directly using Request.getinputstream () binary way to accept uploaded files, but here special attention, need to webuploader this configuration

sendasbinary Change to true  

 var uploader = webuploader.create ({
      swf: './js/webuploader/uploader.swf ',
      Server:common. base_url_dev+ '/file/upload.do ',
      pick: ' #picker ',
      duplicate:false,
      resize:false,
      auto:true
      , Filenumlimit:5,
      sendasbinary:true,//indicating the use of binary upload file
      filesinglesizelimit:5242880,
      //filetype: ' rar, Zip,doc,xls,docx,xlsx,pdf '
      accept: {
        title: ' Intotypes ',
        extensions: ' Rar,zip,doc,xls,docx,xlsx, PDF ',
        mimetypes: '. Rar,.zip,.doc,.xls,.docx,.xlsx,.pdf '
      }
    }); 

2, the use of Common-fileupload this plug-in to receive, not much to say (back-end coder self-knowledge, to provide a related document: http://www.jb51.net/article/94780.htm)

And when the information on the Internet to see a lot of friends are asking,Java backend How to write? How do I accept parameters? Here I have practiced once, for everyone to do the answer, first of all, thanks to our back-end coder, let me suddenly enlightened:

When I gave him the interface does not pass the parameters of the upload file, where he saw the Tomcat log printed out three parameters, respectively, File,filecontenttype,filefilenamez these three parameters, file this parameter after debugging, is my pass the file, Then we'll guess whether there is a default parameter called "File", and going to webuploader this api has been searched to prove that our guesses are correct, as shown below:

There is a default parameter called "File" ............

To solve this problem, paste the following code:

    var uploader = webuploader.create ({
      swf: './js/webuploader/uploader.swf ',
      Server:common. base_url_dev+ '/file/upload.do ',
      pick: ' #picker ',
      duplicate:false,
      resize:false,
      auto:true
      , Filenumlimit:5,
      fileval: "Upload",  //indicates the name of the parameter, and the background also uses this parameter to receive the file
      filesinglesizelimit:5242880,/
      / FileType: ' Rar,zip,doc,xls,docx,xlsx,pdf '
      accept: {
        title: ' Intotypes ',
        extensions: ' Rar,zip,doc, Xls,docx,xlsx,pdf ',
        mimetypes: '. Rar,.zip,.doc,.xls,.docx,.xlsx,.pdf '
      }
    });

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.