簡單實(shí)現(xiàn)限制uploadify上傳個(gè)數(shù)
簡單實(shí)現(xiàn)限制uploadify上傳個(gè)數(shù)
function deleteUrl(){ $("body").on("click",".img-wrap .mask span",function(event){ event.stopPropagation(); var qs=$('#file_upload-queue>div');//所有的隊(duì)列 var id=qs.eq(2).attr('id');//得到第三個(gè)隊(duì)列的id $('#uploadTowedAccredit').uploadify('cancel',id);//這樣就行了,會自動重置隊(duì)列數(shù)量和刪除dom對象,不能直接qs.eq(2).remove(),無效 /* if(!window.confirm("您確定刪除附件?")){ return; } var imgUrl=$(this).parents(".img-wrap").find("img").attr("src"); deleteImage(imgUrl); $(this).parents(".img-wrap").remove(); */ }); };
<li class="blockli clearfix" style="padding-bottom: 5px;"> <span class="left-name"><em class="red-star">*</em>拖機(jī)授權(quán)委托書:</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>請上傳附件,最多上傳${towedAccreditPicMax} 張</span> <div id="towedAccreditDiv" class="up-img-list clearfix"></div> </li>
// 上傳拖機(jī)授權(quán)委托書 function uploadTowedAccreditInit(){ $("#uploadTowedAccredit").uploadify({ 'hideButton':'true', 'preventCaching' : 'true', 'checkExisting':'true', 'swf': SWF, 'uploader':uploadImg, 'debug':false, 'multi': true, 'method': 'post', 'preventCaching' : true, 'removeCompleted' : true, 'removeTimeout' : 10, 'requeueErrors' : true, 'successTimeout' : 30, 'uploadLimit' : ${towedAccreditPicMax}, 'fileObjName' : 'Filedata', //單張圖片最大限制 'fileSizeLimit' : '1024KB', 'fileTypeDesc' : 'Image Files', //僅限上傳jpg格式圖片 'fileTypeExts' : '*.jpg;*.png', 'height': 24, 'width':73, 'buttonText' : '上傳附件', 'auto': true, 'buttonClass':'uploada btn-fff-24', 'onSWFReady' : function() { }, 'onInit':function(){ // $("#file_upload-button").css("width","100"); }, //選擇圖片完成 'onSelect' : function() { }, //取消上傳 'onCancel' : function(file) { }, 'onCheck': function(event,data,key) { }, //開始上傳 'onUploadStart' : function(file) { $('.uploadify-queue').html(''); }, //上傳過程中 'onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) { $('.uploadify-queue').html(''); $("#uploadTowedAccreditLinkTip").html('<em></em>上傳中...'); }, //上傳完成 'onUploadComplete' : function(file) { $('.uploadify-queue').html(''); $("#uploadTowedAccreditLinkTip").html('<em></em>上傳成功,待提交'); }, //上傳成功 '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'><img width='112' height='84' alt='' src='"+filename+"'><div class='mask'><em></em><span></span></div></div>"); } }, //上傳失敗 //附件格式不正確,請上傳JPG、BMP、PNG格式文件,大小不超過3MB 'onUploadError' : function(file, errorCode, errorMsg, errorString) { switch(errorCode) { case -100: alert("上傳的文件數(shù)量已經(jīng)超出系統(tǒng)限制的"+$('#uploadTowedAccredit').uploadify('settings','queueSizeLimit')+"個(gè)文件!"); break; case -110: alert("文件 ["+file.name+"] 大小超出系統(tǒng)限制的"+$('#uploadTowedAccredit').uploadify('settings','fileSizeLimit')+"大??!"); break; case -120: alert("文件 ["+file.name+"] 大小異常!"); break; case -130: alert("文件 ["+file.name+"] 類型不正確!"); break; } }, //上傳失敗 //附件格式不正確,請上傳JPG、BMP、PNG格式文件,大小不超過3MB 'onSelectError' : function(file, errorCode, errorMsg) { var msgText = "上傳失敗\n"; switch (errorCode) { case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: var towedAccreditDivLen = $("#towedAccreditDiv").children().length; msgText += "每次最多上傳 " + $('#uploadTowedAccredit').uploadify('settings','uploadLimit') + "個(gè)文件"; break; case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: msgText += "文件大小超過限制( " + $('#uploadTowedAccredit').uploadify('settings','fileSizeLimit') + " )"; break; case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: msgText += "文件大小為0"; break; case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: msgText += "文件格式不正確,僅限 " + $('#uploadTowedAccredit').uploadify('settings','fileTypeExts'); break; default: msgText += "錯誤代碼:" + errorCode + "\n" + errorMsg; } alert(msgText); } }); //判斷用戶是否有安裝flash var obj = $("#uploadTowedAccredit").children().eq(0); if(obj.attr('type')!= "application/x-shockwave-flash"){ alert('系統(tǒng)檢測到您的瀏覽器沒有安裝flash插件,為了你能夠正常上傳圖片,建議你安裝flash'); return; } $("#uploadTowedAccredit").css("float","left"); };
另外給大家附上jquery+uploadify多文件上傳
<html xmlns=”http://www.w3.org/1999/xhtml”> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ /> <title>php jquery uploadify多文件上傳</title> <link href=”css/default.css” rel=”stylesheet” type=”text/css” /> <link href=”css/uploadify.css” rel=”stylesheet” type=”text/css” /> <script type=”text/javascript” src=”js/jquery-1.3.2.min.js”></script> <script type=”text/javascript” src=”js/swfobject.js”></script> <script type=”text/javascript” src=”js/jquery.uploadify.v2.1.0.min.js”></script> <script type=”text/javascript”> $(document).ready(function() { $(“#fileInput2″).uploadify({ ‘uploader': ‘js/uploadify.swf',//所需要的flash文件 ‘cancelImg': ‘cancel.png',//單個(gè)取消上傳的圖片 'script': ‘js/uploadify.php',//實(shí)現(xiàn)上傳的程序 ‘folder': ‘uploads',//服務(wù)端的上傳目錄 //'auto': true,//自動上傳 ‘multi': true,//是否多文件上傳 //'checkScript': ‘js/check.php',//驗(yàn)證 ,服務(wù)端的 ‘displayData': 'speed',//進(jìn)度條的顯示方式 //'fileDesc': ‘Image(*.jpg;*.gif;*.png)',//對話框的文件類型描述 //'fileExt': ‘*.jpg;*.jpeg;*.gif;*.png',//可上傳的文件類型 //'sizeLimit': 999999 ,//限制上傳文件的大小 //'simUploadLimit' :3, //并發(fā)上傳數(shù)據(jù) //'queueSizeLimit' :5, //可上傳的文件個(gè)數(shù) //'buttonText' :'文件上傳',//通過文字替換鈕扣上的文字 ‘buttonImg': ‘css/images/browseBtn.png',//替換上傳鈕扣 ‘width': 80,//buttonImg的大小 ‘height': 24,// ‘rollover': true,//button是否變換 onComplete: function (evt, queueID, fileObj, response, data) { //alert(“Successfully uploaded: “+fileObj.filePath); //alert(response); getResult(response);//獲得上傳的文件路徑 } //onError: function(errorObj) { // alert(errorObj.info+” “+errorObj.type); //} }); }); </script> <script type=”text/javascript”> function getResult(content){ //通過上傳的圖片來動態(tài)生成text來保存路徑 var board = document.getElementById(“divTxt”); board.style.display=””; var newInput = document.createElement(“input”); newInput.type = “text”; newInput.size = “45″; newInput.name=”myFilePath[]“; var obj = board.appendChild(newInput); var br= document.createElement(“br”); board.appendChild(br); obj.value=content; } </script> </head> <body> <fieldset style=”border: 1px solid #CDCDCD; padding: 8px; padding-bottom:0px; margin: 8px 0″> <legend> <strong> 多文件上傳</strong></legend> <div> <input id=”fileInput2″ name=”fileInput2″ type=”file” /> <input type=”button” value=”確定上傳” onclick=”javascript:$(‘#fileInput2′).uploadifyUpload();”> || <a href=”javascript:$(‘#fileInput2′).uploadifyClearQueue();”>清除上傳列表</a></div> <p></p> </fieldset> <FORM name=”form2″ METHOD=POST ACTION=”db.php”> <div id=”divTxt” style=”display:none”><span style=”color:red”><strong>已經(jīng)上傳的圖片有:</strong></span& gt;<br></div><br> <INPUT TYPE=”submit” value=”提 交”> </FORM> </body> </html>
- JQuery.uploadify 上傳文件插件的使用詳解 for ASP.NET
- JQuery上傳插件Uploadify使用詳解及錯誤處理
- uploadify 3.0 詳細(xì)使用說明
- Jquery上傳插件 uploadify v3.1使用說明
- asp.net(c#)開發(fā)中的文件上傳組件uploadify的使用方法(帶進(jìn)度條)
- uploadify在Firefox下丟失session問題的解決方法
- Jquery Uploadify多文件上傳帶進(jìn)度條且傳遞自己的參數(shù)
- 詳解jquery uploadify 上傳文件
- Jquery uploadify圖片上傳插件無法上傳的解決方法
- Jquery Uploadify上傳帶進(jìn)度條的簡單實(shí)例
- jquery uploadify和apache Fileupload實(shí)現(xiàn)異步上傳文件示例
- jQuery文件上傳插件Uploadify使用指南
- 使用ThinkPHP+Uploadify實(shí)現(xiàn)圖片上傳功能
- php+jQuery.uploadify實(shí)現(xiàn)文件上傳教程
- firefox瀏覽器用jquery.uploadify插件上傳時(shí)報(bào)HTTP 302錯誤
- uploadify多文件上傳參數(shù)設(shè)置技巧
- javascript實(shí)現(xiàn)uploadify上傳格式以及個(gè)數(shù)限制
相關(guān)文章
詳解jQuery獲取特殊屬性的值以及設(shè)置內(nèi)容
在本篇內(nèi)容里小編給大家分享了jQuery獲取特殊屬性的值以及設(shè)置內(nèi)容相關(guān)知識點(diǎn),有需要的朋友們參考下。2018-11-11JQuery 初體驗(yàn)(建議學(xué)習(xí)jquery)
最近從朋友那兒聽說,寫JavaScript,JQuery是個(gè)不錯的東東,市場份額達(dá)到70%之巨。所以去下載了一份體驗(yàn)了一下。2009-04-04jQuery隊(duì)列控制方法詳解queue()/dequeue()/clearQueue()
jQuery核心中, 有一組隊(duì)列控制方法, 這組方法由queue()/dequeue()/clearQueue()三個(gè)方法組成, 它對需要連續(xù)按序執(zhí)行的函數(shù)的控制可以說是簡明自如, 主要應(yīng)用于animate ()方法, ajax以及其他要按時(shí)間順序執(zhí)行的事件中.2010-12-12JQuery簡單實(shí)現(xiàn)錨點(diǎn)鏈接的平滑滾動
在平時(shí)的項(xiàng)目中,我們經(jīng)常需要一些特效鏈接,如果使效果進(jìn)一步加強(qiáng),我們可以使點(diǎn)擊錨點(diǎn)鏈接平滑滾動到錨點(diǎn),下面就來給大家講解下如何使用jQuery來實(shí)現(xiàn)。2015-05-05JQuery實(shí)現(xiàn)用戶名無刷新驗(yàn)證的小例子
本人也是JQuery初學(xué)者,寫了個(gè)用戶名無刷新驗(yàn)證的簡單例子,拿來分享,共同學(xué)習(xí)一下吧。2013-03-03jQuery仿gmail實(shí)現(xiàn)fixed布局的方法
這篇文章主要介紹了jQuery仿gmail實(shí)現(xiàn)fixed布局的方法,涉及jQuery操作頁面元素屬性的相關(guān)技巧,需要的朋友可以參考下2015-05-05jquery css實(shí)現(xiàn)郵箱自動補(bǔ)全
這篇文章主要為大家詳細(xì)介紹了jquery css實(shí)現(xiàn)郵箱自動補(bǔ)全功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11jQuery+CSS3實(shí)現(xiàn)四種應(yīng)用廣泛的導(dǎo)航條制作實(shí)例詳解
這篇文章主要介紹了jQuery+CSS3實(shí)現(xiàn)多種類型的導(dǎo)航條制作實(shí)例詳解的相關(guān)資料,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2016-09-09jQuery實(shí)現(xiàn)公告文字左右滾動的實(shí)例代碼
這篇文章介紹了jQuery實(shí)現(xiàn)公告文字左右滾動的實(shí)例代碼,有需要的朋友可以參考一下2013-10-10