最近想做一个上传的总结,把自己用过的上传插件都写一写,哪天用到的时候就不用再一次的翻阅资料,现在页面上用到的上传插件,原理上都差不多,那我也就不再废话了,下面我主要记录一下几个比较常用的,由简到繁,这里我只写代码,其它的就不在啰嗦了:

  • jquery.upload.js
  • ajaxupload.js
  • uploadify
  • SWFUpload

 

jquery.upload.js


  这里只写主要的,至于js的引用我就不用说了是吧,自己添加上就行,我就不写了。

  前台html代码:

 1 <html>
 2 <head>
 3     <meta name="viewport" content="width=device-width" />
 4     <title></title>
 5     <script>
 6         /*文件上传*/
 7         function upload() {
 8             $.upload({                      // 上传方法
 9                 url: '/System/Upload',      // 上传地址
10                 fileName: 'uploadfile',     // 文件域名字
11                 params: { name: 'pxblog' }, // 其他表单数据
12                 dataType: 'json',           // 上传完成后, 返回json, text
13                 onSend: function () {       // 上传之前回调,return true表示可继续上传
14                     return true;
15                 },
16                 onSubmit: function () {
17                 },
18                 onComplate: function (data) {   // 上传之后回调
19                     if (data.msg) {
20 
21                     } else {
22                         alert("上传图片出错!");
23                     }
24                 }
25             })
26         }
27     </script>
28 </head>
29 <body>
30     <div>
31         <input type="button" onclick="upload()" value="点击上传" />
32     </div>
33 </body>
34 </html>
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
  • 2022-01-07
  • 2021-12-17
  • 2022-12-23
  • 2021-11-06
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2021-04-15
  • 2021-09-04
  • 2022-12-23
相关资源
相似解决方案