亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

jquery實(shí)現(xiàn)上傳文件進(jìn)度條

 更新時(shí)間:2020年03月26日 09:28:50   作者:月慕向陽(yáng)  
這篇文章主要為大家詳細(xì)介紹了jquery實(shí)現(xiàn)上傳文件進(jìn)度條,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了jquery實(shí)現(xiàn)上傳文件進(jìn)度條的具體代碼,供大家參考,具體內(nèi)容如下

首先引入需要的js  css

用bootstrap進(jìn)度條

<link rel="stylesheet" href="js/bootstrap/bootstrap.min.css" >
<script type="text/javascript" src="js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="js/jquery.form.js"></script>

前端頁(yè)面

<form id="uploadFile" action="uploadFile" enctype="multipart/form-data">
 <input type="file" name="file">
 <input type="button" value="上傳" id="uplodsss">
 </form>
 <div class="progress">
 <div id="uploadFile_progressBar" class="progress-bar" role="progressbar" aria-valuenow="60" 
 aria-valuemin="0" aria-valuemax="100" style="min-width: 2em;">
 <span id="uploadFile_rate">0%</span>
 </div>
 </div>

js

<script type="text/javascript">
$(function(){
 $("#uplodsss").click(function(){
 debugger
 $('#uploadFile').ajaxSubmit({
  type:'post', 
  url:"uploadFile", 
  processData: false, //需設(shè)置為false,因?yàn)閐ata值是FormData對(duì)象,不需要對(duì)數(shù)據(jù)做處理
  contentType: false, //需設(shè)置為false,因?yàn)槭荈ormData對(duì)象,且已經(jīng)聲明了屬性enctype="multipart/form-data"
  resetForm: true, //成功提交后,是否重置所有表單元素的值
 uploadProgress: function (event, position, total, percentComplete) {
 if(percentComplete > 100){
 percentComplete = 100;
 }
 var percentVal = percentComplete + '%'; 
 $("#uploadFile_rate").html(percentVal); // 文件上傳進(jìn)度顯示值
 $("#uploadFile_progressBar").width(percentVal); // 進(jìn)度條狀態(tài)
 
 }, 
 success:function(data){
 alert("上傳文件成功!");
  $("#uploadFile_progressBar").width("0px"); // 進(jìn)度條狀態(tài)
  $("#uploadFile_rate").html("0%");
  },
  error:function(){ 
  alert("上傳文件失敗,請(qǐng)重試!");
  }
 });
 });
})
</script>

需要jquery.form.js,下載地址

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論