




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
【移動(dòng)應(yīng)用開發(fā)技術(shù)】angularJS上傳文件
<divclass="col-lg-1col-sm-1pull-right">
<aid="fileb"href="javascript:;"name="file"ng-show="jIn">
<inputtype="file"nv-file-select=""uploader="uploader1"multiple/><aclass="btnbtn-info
btn-sm"ng-show="jIn">導(dǎo)入</a>
</a>
</div>//導(dǎo)入
varuploader1=$scope.uploader1=newFileUploader({
url:'http://localhost:8080/importWorkBook?loanChannel=005',
autoUpload:true
});
//FILTERS
uploader1.filters.push({
name:'customFilter',
fn:function(item/*{File|FileLikeObject}*/,options){
returnthis.queue.length<10;
}
});
//CALLBACKS
uploader1.onWhenAddingFileFailed=function(item/*{File|FileLikeObject}*/,filter,options){//
('onWhenAddingFileFailed',item,filter,options);
};
uploader1.onAfterAddingFile=function(fileItem){//
('onAfterAddingFile',fileItem);
};
uploader1.onAfterAddingAll=function(addedFileItems){//
('onAfterAddingAll',addedFileItems);
};
uploader1.onBeforeUploadItem=function(item){//
('onBeforeUploadItem',item);
};
uploader1.onProgressItem=function(fileItem,progress){//
('onProgressItem',fileItem,progress);
};
uploader1.onProgressAll=function(progress){//
('onProgressAll',progress);
};
uploader1.onSuccessItem=function(fileItem,response,status,headers){
if(response.returnMsg=="ok"){
swal({
title:"導(dǎo)入成功",
text:"",
type:"success",
timer:1300,
showConfirmButton:false
});
$cessingInfo();
}else{
swal({
title:"導(dǎo)入失敗",
text:"對(duì)不起,數(shù)據(jù)有誤,導(dǎo)入失敗!",
type:"error",
timer:1300,
showConfirmButton:false
});
$cessingInfo();
}//
('onSuccessItem',fileItem,response,status,headers);
};
uploader1.onErrorItem=function(fileItem,response,status,headers){//
('onErrorItem',fileItem,response,status,headers);
};
uploader1.onCancelItem=function(fileItem,response,status,headers){//
('onCancelItem',fileItem,response,status,headers);
};
uploader1.onCompleteItem=function(fileItem,response,status,headers){//
('onCompleteItem',fileItem,response,status,headers);
};
uploader1.onCompleteAll=function(){//
('onCompleteAll');
};//
('uploader',uploader);
控制多文件上傳及文件類型
accept="p_w_picpath/*"
multiplenv-file-drop<!--
最少配置
--><elementnv-file-dropuploader="{FileUploader}"></element><!--
最多配置
--><elementnv-file-dropuploader="{FileUploader}"options="{Object}"filters="{String}"></element>屬性
uploader
必須是
FileUploader的一個(gè)實(shí)例。屬性
options
可能是
{FileItem}
的設(shè)置或者自定義設(shè)置。屬性
filters
可能是用,隔開的過(guò)濾器名稱,比如:
'filterName1,
filterName2',這些過(guò)濾器必須如下預(yù)定義:uploader.filters.push({name:'filterName1',
fn:function()
{/*
your
code
here
*/}});
uploader.filters.push({name:'filterName2',
fn:function()
{/*
your
code
here
*/}});nv-file-select<!--
最少配置
--><inputtype="file"nv-file-selectuploader="{FileUploader}"/><!--
最多配置
--><inputtype="file"nv-file-selectuploader="{FileUploader}"options="{Object}"filters="{String}"/>nv-file-over<!--
最少配置
--><elementnv-file-overuploader="{FileUploader}"></element><!--
最多配置
--><elementnv-file-overuploader="{FileUploader}"over-class="{String}"></element>FileUploaderFileUploader屬性u(píng)rl
{String}:上傳文件的服務(wù)器路徑alias
{String}:
包含文件的名稱,默認(rèn)是filequeue
{Array}:上傳隊(duì)列progress
{Number}:上傳隊(duì)列的進(jìn)度,只讀headers
{Object}:上傳的頭文件信息,瀏覽器需支持HTML5formData
{Array}:
與文件一起發(fā)送的表單數(shù)據(jù)filters
{Array}:在文件加入上傳隊(duì)列之前應(yīng)用過(guò)濾器.,如果過(guò)濾器返回true則文件加入隊(duì)列中autoUpload
{Boolean}:文件加入隊(duì)列之后自動(dòng)上傳,默認(rèn)是falsemethod
{String}:請(qǐng)求方式,默認(rèn)是POST,瀏覽器需支持HTML5removeAfterUpload
{Boolean}:文件上傳成功之后從隊(duì)列移除,默認(rèn)是falseisHTML5
{Boolean}:
如果瀏覽器支持HTML5上傳則返回true,只讀isUploading
{Boolean}:
文件正在上傳中返回true,只讀queueLimit
{Number}
:最大上傳文件數(shù)量(預(yù)定義)withCredentials
{Boolean}
:使用CORS,默認(rèn)是false,
瀏覽器需支持HTML5方法addToQueue
function(files[,options[,filters]]){:Additems
tothequeue,where
files
isa
{FileList|File|HTMLInputElement},
options
is
an
{Object}
andfilters
isa
{String}.
添加項(xiàng)到上傳隊(duì)列中,files
是
{FileList|File|HTMLInputElement},
options
是
{Object}
以及
filters
是
{String}removeFromQueue
function(value){:Removeanitemfromthequeue,
wherevalue
is
{FileItem}
or
indexofitem.
從上傳隊(duì)列移除項(xiàng),value
可以是
{FileItem}
或者項(xiàng)的序號(hào)clearQueue
function(){:Removesallelementsfromthequeue.
移除上傳隊(duì)列所有的元素uploadItem
function(value){:Uploadsanitem,where
value
is
{FileItem}
or
indexofitem.
上傳項(xiàng),
value
可以是
{FileItem}
或者項(xiàng)的序號(hào)cancelItem
function(value){:Cancelsuploadingofitem,where
value
is{FileItem}
or
indexofitem.
取消上傳的項(xiàng)uploadAll
function(){:Uploadallpendingitemsonthequeue.
將上傳隊(duì)列中所有的項(xiàng)進(jìn)行上傳cancelAll
function(){:Cancelsallcurrentuploads.
取消所有當(dāng)前上傳destroy
function(){:Destroysauploader.
isFile
function(value){return{Boolean};}:Returnstrueif
valueis
{File}.
isFileLikeObject
function(value){return{Boolean};}:Returns
trueifvalueis{FileLikeObject}.getIndexOfItem
function({FileItem}){return{Number};}:Returns
theindexofthe{FileItem}
queueelement.
返回項(xiàng)在上傳隊(duì)列中的序號(hào)getReadyItems
function(){return{Array.<FileItems>};}:Return
itemsarereadytoupload.
返回準(zhǔn)備上傳的項(xiàng)getNotUploadedItems
function(){return{Array.<FileItems>};}:
Returnanarrayofallpendingitemsonthequeue
返回上傳隊(duì)列中未上傳的項(xiàng)回調(diào)函數(shù)onAfterAddingFile
function(item){:添加文件到上傳隊(duì)列后onWhenAddingFileFailed
function(item,filter,options){:添加文件到上傳隊(duì)列失敗后onAfterAddingAll
function(addedItems){:添加所選的所有文件到上傳隊(duì)列后onBeforeUploadItem
function(item){:文件上傳之前onProgressItem
function(item,progress){:文件上傳中onSuccessItem
function(item,response,status,headers){:文件上傳成功后onErrorItem
function(item,response,status,headers){:文件上傳失敗后onCancelItem
function(item,response,status,headers){
-文件上傳取消后onCompleteItem
function(item,response,status,headers){:
文件上傳完成后onProgressAll
function(progress){:上傳隊(duì)列的所有文件上傳中onCompleteAll
function(){:上傳隊(duì)列的所有文件上傳完成后成功上傳文件的回調(diào)函數(shù)順序是:onAfterAddingFile
—onAfterAddingAll
—
onBeforeUploadItem
—
onProgressItem
—
onProgressAll
—
onSuccessItem
—
onCompleteItem
—
onCompleteAllFileItem屬性u(píng)rl
{String}:Pathontheserverinwhichthisfilewillbe
uploaded
上傳文件的服務(wù)器路徑alias
{String}:Nameofthefieldwhichwillcontainthefile,
defaultis
file
包含文件的名稱,默認(rèn)是fileheaders
{Object}:Headerstobesentalongwiththisfile.HTML5
browsersonly.
上傳的頭文件信息,瀏覽器需支持HTML5formData
{Array}:Datatobesentalongwiththisfile
與文件一起發(fā)送的表單數(shù)據(jù)method
{String}:It'sarequestmethod.Bydefault
POST.
HTML5browsersonly.
請(qǐng)求方式,默認(rèn)是POST,瀏覽器需支持HTML5withCredentials
{Boolean}
:enableCORS.HTML5browsersonly.
使用CORS,默認(rèn)是false,
瀏覽器需支持HTML5removeAfterUpload
{Boolean}:Removethisfilefromthequeue
afteruploading
上傳之后從上傳隊(duì)列移除該文件index
{Number}
-Asequencenumberupload.Readonly.
上傳文件在上傳隊(duì)列中的序號(hào),只讀progress
{Number}:Fileuploadprogresspercentage.Readonly.
文件上傳的進(jìn)度,只讀isReady
{Boolean}
-Fileisreadytoupload.Readonly.
文件是否準(zhǔn)備好上傳,只讀isUploading
{Boolean}:
true
if
thefileisbeinguploaded.Readonly.
文件是否正在上傳中,只讀isUploaded
{Boolean}:
true
if
thefilewasuploaded.Readonly.
文件是否已經(jīng)上傳,只讀isSuccess
{Boolean}:
true
if
thefilewasuploadedsuccessfully.Readonly.
文件是否已經(jīng)上傳成功,只讀isCancel
{Boolean}
:
true
if
uploadingwascanceled.Readonly.
文件是否取消上傳,只讀isError
{Boolean}
-
true
if
occurrederrorwhilefileuploading.Readonly.
文件是否上傳錯(cuò)誤,只讀uploader
{Object}:Referencetotheparent
Uploader
object
forthisfile.Readonly.
上傳該文件的Uploader
,只讀方法remove
function(){:Removethisfilefromthequeue
從上傳隊(duì)列移除該文件upload
function(){:Uploadthisfile
上傳該文件cancel
function(){:Cancelsuploadingofthisfile
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 上海嘉善房屋出租合同范本
- 高中課題申報(bào)書
- 課題申報(bào)書亮點(diǎn)
- 臨時(shí)用工勞務(wù)合同范本 三
- 勞務(wù)拆遷采購(gòu)合同范本
- 合同范本 材料價(jià)差調(diào)整
- 勞務(wù)公司包工合同范本
- 與中介簽買房合同范本
- 中泰大米合同范本
- 中央食堂資質(zhì)合同范本
- 2022年江蘇省錄用公務(wù)員筆試《公安專業(yè)科目》試題(網(wǎng)友回憶版)
- 光伏電站螺旋地樁承載力計(jì)算軟件
- 醫(yī)用耗材配送服務(wù)方案
- 風(fēng)力發(fā)電場(chǎng)建設(shè)項(xiàng)目初步(概要)設(shè)計(jì)
- 中職統(tǒng)編《金屬材料與熱處理》系列課件 第3章 鐵碳合金(動(dòng)畫) 云天系列課件
- 新蘇教版六年級(jí)科學(xué)下冊(cè)全冊(cè)知識(shí)點(diǎn)
- QC成果勁鋼混凝土結(jié)構(gòu)鋼骨柱梁安裝質(zhì)量控制
- 國(guó)家公務(wù)員考試準(zhǔn)考證模板
- 緒論歷史地理學(xué)
- 中小學(xué)教師學(xué)生心理健康教育及案例
- 2024年四川省綿陽(yáng)市中考物理試題 2024年綿陽(yáng)中考分?jǐn)?shù)線
評(píng)論
0/150
提交評(píng)論