var stopAjax='' $('#delUploadBtn').on('click',function () { stopAjax.abort(); })
$('#file').on('change',function () { var videoUrl=$(this).val(); var urlType=videoUrl.substring(videoUrl.lastIndexOf(".")).toLowerCase(); if(!urlType.match(/.mp4|.flv|.avi|.rmvb|.wmv|.mov|.mkv|.rm|.mpg|.webm|.mpeg4|.ts/)){ alert('上传错误,视屏格式必须为:mp4/flv/avi/rmvb/wmv/mov/mkv/rm/mpg/webm/mpeg4/ts') }else{ $('#videoName').html($(this).val().slice($(this).val().lastIndexOf("\\")+1)) ajaxUploadingFn() } })
function onprogress(evt){ var loaded = evt.loaded; var tot = evt.total; var per = Math.floor(100*loaded/tot); $('.baifenbiNum').html(per +"%") $('.baifenbiWid').css("width" , per +"%"); } function ajaxUploadingFn() { var videoText=new FormData(); videoText.append("file" , $("#file").files[0]); stopAjax=$.ajax({ url:"xxxxxxx", type:'post', dataType:'json', data:videoText, processData : false, contentType : false , xhr: function(){ var xhr = $.ajaxSettings.xhr(); if(onprogress && xhr.upload) { xhr.upload.addEventListener("progress" , onprogress, false); return xhr; } }, success:function (res) { if(data.code==1){ XXXXX } } }) }
|