This article for everyone to share the JavaScript implementation uploadify upload format and the number of restrictions on the key code, I hope we study hard.
Key code One:
function DeleteUrl () {
$ (' body '). On ("click", ". Img-wrap. Mask span", function (event) {
event.stoppropagation ( );
var qs=$ (' #file_upload-queue>div ');//All Queues
var id=qs.eq (2). attr (' id '); the ID of the third queue
$ (' # Uploadtowedaccredit '). Uploadify (' Cancel ', id);//This will do, automatically reset the number of queues and delete Dom objects, not directly Qs.eq (2). Remove (), invalid//
if ( !window.confirm ("Are you sure you deleted the attachment?") ")) {return
;
}
var imgurl=$ (this). Parents (". Img-wrap"). FIND ("img"). attr ("src");
DeleteImage (Imgurl);
$ (this). Parents (". Img-wrap"). Remove ();
*/
});
};
Key code two:
<li class= "Blockli clearfix" style= "padding-bottom:5px;" >
<span class= "left-name" ><em class= "Red-star" >*</em> towage power of Attorney:</span>
<div class= "Upload-wrap" style= "width:100px;" >
<input type= "file" Name= "Uploadtowedaccredit" id= "Uploadtowedaccredit" class= "Filetext"/>
</ div>
<span id= "Uploadtowedaccreditlinktip" class= "warn-tips" ><em></em> please upload the attachment, upload the maximum ${ Towedaccreditpicmax} Zhang </span>
<div id= "Towedaccreditdiv" class= "Up-img-list clearfix" ></div>
</li>
Key code Three:
Upload the Tow machine authorization function Uploadtowedaccreditinit () {$ ("#uploadTowedAccredit"). Uploadify ({' Hidebutton ': ' true ', ' p Reventcaching ': ' true ', ' checkexisting ': ' true ', ' swf ': swf, ' uploader ': uploadimg, ' Debug ': false, ' mu
LTI ': True, ' method ': ' Post ', ' preventcaching ': true, ' removecompleted ': true, ' removetimeout ': 10, ' Requeueerrors ': true, ' successtimeout ': ' Uploadlimit ': ${towedaccreditpicmax}, ' Fileobjname ': ' Filedata ',//single picture maximum limit ' filesizelimit ': ' 1024KB ', ' filetypedesc ': ' Image Files ',//upload JPG image only ' file ' Typeexts ': ' *.jpg;*.png ', ' height ': ', ' width ': ' buttontext ': ' Upload attachment ', ' auto ': true, ' Buttonclass ': ' Uploada btn-fff-24 ', ' Onswfready ': function () {}, ' OnInit ': function () {//$ ("#file_upload
-button "). CSS (" width "," 100 "); //Select Picture Complete ' onselect ': function () {},//Cancel uploading ' OnCancel ': Function (file) {}, ' Oncheck ': function (Event,data,key) {},//Start uploading ' onuploadstart ': function (file) {$ ('. u
Ploadify-queue '). html ('); ' Onuploadprogress ': function (file, bytesuploaded, Bytestotal, totalbytesuploaded, Totalbytestota, upload process)
L) {$ ('. Uploadify-queue '). html (');
$ ("#uploadTowedAccreditLinkTip"). html (' <em></em> upload ... ');
//upload complete ' onuploadcomplete ': function (file) {$ ('. Uploadify-queue '). html (');
$ ("#uploadTowedAccreditLinkTip"). html (' <em></em> upload successful, pending submission ');
},//Upload success ' onuploadsuccess ': function (file, data, response) {var obj = eval (' + data + ') ');
var Result=obj.result;
if (result== "true") {var filename=obj.filename;
$ ('. Uploadify-queue '). html ('); $ (' #towedAccreditDiv '). Append ("<div class= ' img-wrap ' ><div class= ' mask ' ><em≫</em><span></span></div></div> "); },////Upload failed//attachment format is incorrect, please upload jpg, BMP, PNG format file, size not exceeding 3MB ' onuploaderror ': function (file, errorcode, ErrorMsg, errorstring) {switch (errorcode) {Case-100:alert ("the number of uploaded files has exceeded the system limit" +$ (' #uploadTowedAccredit '). u Ploadify (' Settings ', ' queuesizelimit ') + "Files!
");
Break Case-110:alert ("+file.name+"] size exceeds the system-limited "+$" (' #uploadTowedAccredit '). Uploadify (' Settings ', ' filesizelimit ') + Size
");
Break Case-120:alert ("file [" +file.name+] size is abnormal!)
");
Break Case-130:alert ("file [" +file.name+] type is incorrect!)
");
Break
},////Upload failed//attachment format is incorrect, please upload jpg, BMP, PNG format file, size not exceeding 3MB ' onselecterror ': function (file, errorcode, errormsg) {
var msgtext = "Upload failed \ n"; Switch (errorcode) {case Swfupload.queue_error. Queue_limit_exceeded:var Towedaccreditdivlen = $ ("#towedAccreditDiv"). Children (). length;
Msgtext + = "Upload every time" + $ (' #uploadTowedAccredit '). Uploadify (' Settings ', ' uploadlimit ') + "files";
Break Case Swfupload.queue_error. File_exceeds_size_limit:msgtext + = "File size exceeds limit (" + $ (' #uploadTowedAccredit '). Uploadify (' Settings ', ' Filesizelimi
T ') + ")";
Break Case Swfupload.queue_error.
Zero_byte_file:msgtext + = "File size is 0";
Break Case Swfupload.queue_error.
Invalid_filetype:msgtext + = "file format is incorrect, only" + $ (' #uploadTowedAccredit '). Uploadify (' Settings ', ' filetypeexts ');
Break
Default:msgtext + = "Error code:" + errorcode + "\ n" + errormsg;
alert (Msgtext);
}
});
Determine if the user has installed flash var obj = $ ("#uploadTowedAccredit"). Children (). EQ (0);
if (obj.attr (' type ')!= "Application/x-shockwave-flash") {alert (' The system detects that your browser does not have a flash plugin installed, so that you can upload the image correctly, we recommend that you install Flash ');
Return
} $ ("#uploadTowedAccredit"). CSS ("float", "left"); };
How JavaScript restricts the Uploadify upload format and number The problem I hope that through this article we should have a certain understanding, hope can really help you solve the uploadify upload number and format limitations of the problem.