Webuploader plug-in usage analysis

Source: Internet
Author: User
Tags rar

Approximate architecture:

Front End: Html5+ajax

Backend: Java (Struts framework related)

Problems encountered:

Backstage coder provides 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 plugin, do not know how this thing custom parameters ... After a variety of Google, Baidu, found the following two kinds of solutions:

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

Sendasbinary Change to True

  

  varuploader =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,//indicates that the file is uploaded using binary modefilesinglesizelimit: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, use common-fileupload this plug-in received, not much said (backend coder self-knowledge, provide a copy of the relevant documents: http://blog.csdn.net/a352193394/article/details/7477041)

And on the Internet when the information 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 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, he saw the Tomcat log print out three parameters, respectively, File,filecontenttype,filefilenamez these three parameters, file this parameter after debugging, I passed the file, Then we guess there is a default parameter called "File", go to Webuploader this api has been searched to prove that our guesses are correct, such as:

  

Sure enough, there is a default parameter called "File" ...... .....

At this point the problem is solved, paste the following code:

        varuploader =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 filefilesinglesizelimit: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 '            }        });

Welcome to shoot the bricks ..... ......

Webuploader plug-in usage analysis

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.