The plupload limit allows you to upload only one image,

Source: Internet
Author: User

The plupload limit allows you to upload only one image,

Var files = []; var errors = [];
Var chunk = <% = request. getParameter ("chunk") %>;
Var root = "", xml = "";
Var max_file_size = '20mb ';
Var image = '<% = request. getParameter ("image") %> ';
Var id = '<% = request. getParameter ("id") %> ';
Var flag = '<% = request. getParameter ("flag") %> ';
Var conDir = '<% = request. getParameter ("conDir") %> ';
Var filters = {title: "allowed file types", extensions: "jpg, gif, png "};
$ ("# Uploader"). pluploadQueue ($. extend ({
Runtimes: 'flash ',
Url: '<% = path %>/uploaderxing? Id = '+ id +' & flag = '+ flag +' & conDir = '+ conDir +' & image = '+ image,
Max_file_size: max_file_size,
File_data_name: 'file ',
Unique_names: true,

// Only one file or image can be selected in the selected flash.
Multi_selection: false,
Filters: [filters],
Flash_swf_url: '<% = path %>/upload/plupload/plupload.flash.swf ',
Init :{
FileUploaded: function (uploader, file, response ){
If (response. response ){
Var rs = $. parseJSON (response. response );
If (rs. status ){
Xml + = '<name> <! [CDATA ['+ file. name +']> </name> ';
Xml + = '<size>' + file. size + '</size> ';
Xml + = '<newName>' + rs. newName + '</newName> ';
Xml + = '<savePath>' + rs. savePath + '</savePath> ';
Files. push (xml );
} Else {
Errors. push (file. name );
}
}
},

// After this method is added, only one file or image can be uploaded.
FilesAdded: function (uploader, files ){
$. Each (uploader. files, function (I, file ){
If (uploader. files. length <= 1 ){
Return;
}
Uploader. removeFile (file );
});
},
UploadComplete: function (uploader, fs ){
Window. parent. location. reload ();
Window. parent. reloadJQGrid ();
Target. window ("close ");
}
}
},
(Chunk? {Chunk_size: max_file_size }:{})));

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.