Plupload how to control the minimum width and file type

Source: Internet
Author: User

Directly on the code

Plupload.addfilefilter (' Min_width ',function(maxwidth, file, CB) {varSelf = This, IMG =NewO.image (); functionFinalize (Result) {//CleanupImg.destroy (); IMG=NULL; //If rule has been violated in one-or another, trigger an error            if(!result) {Self.trigger (' Error ', {code:plupload. Image_dimensions_error, message:"Picture width cannot be less than" + MaxWidth + "px", file:file});        } CB (Result); } img.onload=function () {            //Check if resolution cap is not exceededFinalize (Img.width >=maxwidth);        }; Img.onerror=function() {Finalize (false);        };    Img.load (File.getsource ());    }); Plupload.addfilefilter (' FileType ',function(filetype, file, cb) {varSelf = This, IMG =NewO.image (); functionFinalize (Result) {//CleanupImg.destroy (); IMG=NULL; //If rule has been violated in one-or another, trigger an error            if(!result) {Self.trigger (' Error ', {code:plupload. Image_dimensions_error, message:"The image format you uploaded is" + File.type + "and can only upload jpg images", file:file});        } CB (Result); } img.onload=function () {            //Check if resolution cap is not exceeded            varType =File.type; Type= Type.replace ("image/", "" "); Finalize (Filetype.indexof (type)> 0);        }; Img.onerror=function() {Finalize (false);        };     Img.load (File.getsource ());    }); varuploader =NewPlupload. Uploader ({//to create an instance construction methodBrowse_button: ' Fileinput-button ', runtimes:' Html5,flash,silverlight,html4 ',//Upload Plugin Initialize the order of precedence in that wayURL: "/common/imageup",//Remote Upload AddressMax_file_size: ' 20MB ', Chunk_size:' 500KB ', Filters: {title:"Image files", filetype: "Jpg,jpeg", min_width:600}, Flash_swf_url:'/scripts/plupload-2.1.9/moxie.swf ',     }); Uploader.init ();

Reference article:

Http://stackoverflow.com/questions/14091505/control-image-width-and-height-when-upload-image

Plupload how to control the minimum width and file type

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.