知识站

 找回密码
 立即注册
知识站 首页 html 查看内容

jquery file upload示例

2020-3-4 08:37| 发布者: admin| 查看: 14| 评论: 0

摘要: jquery file upload是一款实用的上传文件插件,项目中刚好用到,在这里记录分享一下。一:准备相关js文件jquery file upload 下载地址:点击打开链接 点击下面红圈中的按钮下载jquery.js下载地址:点击打开链接二: ...

jquery file upload是一款实用的上传文件插件,项目中刚好用到,在这里记录分享一下。


一:准备相关js文件

jquery file upload 下载地址:点击打开链接  点击下面红圈中的按钮下载



jquery.js下载地址:点击打开链接


二:导入js文件

注意:js文件引入的先后顺序不可以乱

[html] view plain copy
  1. <script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>  
  2. <!-- jquery file upload相关js -->  
  3. <script src="js/jquery.ui.widget.js"></script>  
  4. <script src="js/jquery.iframe-transport.js"></script>  
  5. <script src="js/jquery.fileupload.js"></script>  
  6. <script src="js/jquery.fileupload-process.js"></script>  
  7. <script src="js/jquery.fileupload-validate.js"></script>  


三:jsp代码

[html] view plain copy
  1. <style>  
  2. /* input样式 */  
  3. #uploadImg{  
  4. display: none;  
  5. }  
  6.   
  7. /* button样式 */  
  8. #chooseFile{  
  9. background: #93b6fc;  
  10. }  
  11.   
  12. #uploadFile,#rechooseFile {  
  13. display: none;  
  14. background: #93b6fc;  
  15. }  
  16.   
  17. #image{  
  18.   width:200px;  
  19.   height:200px;  
  20. }  
  21.   
  22. /* 进度条样式 */  
  23. .bar {   
  24.  background-image: -webkit-linear-gradient(top,#5cb85c 0,#449d44 100%);   
  25.  background-image: -o-linear-gradient(top,#5cb85c 0,#449d44 100%);   
  26.  background-image: -webkit-gradient(linear,left top,left bottom,from(#5cb85c),to(#449d44));   
  27.  background-image: linear-gradient(to bottom,#5cb85c 0,#449d44 100%);   
  28.  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5cb85c'endColorstr='#ff449d44'GradientType=0);   
  29.  background-repeat: repeat-x;   
  30.  height: 20px;   
  31.  line-height: 20px;   
  32.  -webkit-box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);   
  33.  box-shadow: inset 0 -1px 0 rgba(0,0,0,.15);   
  34.  -webkit-transition: width .6s ease;   
  35.  -o-transition: width .6s ease;   
  36.  transition: width .6s ease;   
  37. }  
  38. #progress {   
  39.  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffebebeb'endColorstr='#fff5f5f5'GradientType=0);   
  40.  background-repeat: repeat-x;   
  41.  height: 20px;   
  42.  width: 0%;   
  43.  margin-bottom: 20px;   
  44.  overflow: hidden;   
  45.  background-color: #f5f5f5;   
  46.  border-radius: 4px;   
  47.  -webkit-box-shadow: inset 0 1px 2px rgba(0,0,0,.1);   
  48.  box-shadow: inset 0 1px 2px rgba(0,0,0,.1);   
  49.  margin-top: 20px;   
  50. }  
  51. </style>  
  52. <body>  
  53.     <div class="jquery-fileupload">  
  54.         <div class="">  
  55.             <input id="uploadImg" type="file" name="uploadImg" multiple style="display: none" />   
  56.                 <button id="chooseFile">+选择文件</button>   
  57.                 <button id="uploadFile">~开始上传</button>  
  58.                 <button id="rechooseFile">+重新选择</button>  
  59.         </div>  
  60.         <div>  
  61.             <img id="image" src="">  
  62.         </div>  
  63.         <div id="progress"&
发表评论

最新评论

Archiver|知识站 ( 鲁ICP备20004068号-1 )

鲁公网安备 37132502371390号

GMT+8, 2020-6-23 22:50 , Processed in 0.016731 second(s), 17 queries .

返回顶部