js實(shí)現(xiàn)帶進(jìn)度條提示的多視頻上傳功能
更新時(shí)間:2020年12月13日 11:33:43 作者:喵生初現(xiàn)
這篇文章主要為大家詳細(xì)介紹了js實(shí)現(xiàn)帶進(jìn)度條提示的多視頻上傳功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
本文實(shí)例為大家分享了js帶進(jìn)度條上傳多視頻的具體代碼,供大家參考,具體內(nèi)容如下
效果:
引用:
<link rel="stylesheet" href="bootstrap.css" > <script src="jquery.fileupload.js"></script> <script src="http://malsup.github.com/jquery.form.js"></script>
html:
<div class="form-group"> <label>產(chǎn)品視頻:</label> <div class="videoUpfile"> <input type="file" name="avatarVideo" class="avatarVideo"><a class="btn deleteAvatarVideo" href="javascript:;" >刪除</a> <div class="videoMaterials"> <div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 0%"> <span class="sr-only">0% Complete</span> </div> </div> <div class="files"></div> <div class="showimg"></div> <input type="hidden" value="" name="video_id[]"> <p style="color: #b92c28" class="img_upload_info"></p> </div> </div> <div class="videoUpfile"> <input type="file" name="avatarVideo" class="avatarVideo"><a class="btn deleteAvatarVideo" href="javascript:;" >刪除</a> <div class="videoMaterials"> <div class="progress"> <div class="progress-bar progress-bar-success progress-bar-striped" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 0%"> <span class="sr-only">0% Complete</span> </div> </div> <div class="files"></div> <div class="showimg"></div> <input type="hidden" value="" name="video_id[]"> <p style="color: #b92c28" class="img_upload_info"></p> </div> </div> </div>
script:
//上傳視頻 $(".avatarVideo").change(function() { var _this = $(this); _this.wrap("<form class='fileUploadeVideo' action='/admin/uploadimg/addVideo' method='post' enctype='multipart/form-data'></form>"); _this.parents('.fileUploadeVideo').ajaxSubmit({ dataType: 'json', beforeSend: function () { $(".progress").show(); }, uploadProgress: function (event, position, total, percentComplete) { var percentVal = percentComplete + '%'; _this.parents('.videoUpfile').find(".progress-bar").width(percentComplete + '%'); _this.parents('.videoUpfile').find(".progress-bar").html(percentVal); _this.parents('.videoUpfile').find(".sr-only").html(percentComplete + '%'); }, success: function (data) { if(data.code==100) { _this.parents('.videoUpfile').find(".files").html("文件名: " + data.video_title); _this.parents('.videoUpfile').find("input[type=hidden]").val(data.video_id); alert("上傳成功!"); }else{ alert("上傳失敗"); } }, error: function () { alert("上傳失敗"); } });
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
值得分享的Bootstrap Ace模板實(shí)現(xiàn)菜單和Tab頁效果
這篇文章主要為大家分享了基于Bootstrap Ace模板實(shí)現(xiàn)菜單和Tab頁效果,感興趣的小伙伴們可以參考一下2015-12-12JS 實(shí)現(xiàn)倒計(jì)時(shí)數(shù)字時(shí)鐘效果【附實(shí)例代碼】
下面小編就為大家?guī)硪黄狫S 實(shí)現(xiàn)倒計(jì)時(shí)數(shù)字時(shí)鐘效果【附實(shí)例代碼】。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做一個(gè)參考。2016-03-03JavaScript尾遞歸的實(shí)現(xiàn)及應(yīng)用場景
本文主要介紹了JavaScript尾遞歸的實(shí)現(xiàn)及應(yīng)用場景,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05javascript 文本框水印/占位符(watermark/placeholder)實(shí)現(xiàn)方法
html5為表單元素(type為text/password/search/url/telephone/email)新增了一個(gè)placeholder屬性,為輸入框提供一種提示2012-01-01