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.