Back

使用jquery upload的步骤 (steps using jquery)

发布时间: 2013-07-28 09:09:00

refer to: https://github.com/blueimp/jQuery-File-Upload

jquery upload plugin 是迄今为止我见过的人气最旺的GITHUB 项目。 

步骤: 

1. 下载源代码。 git clone https://github.com/blueimp/jQuery-File-Upload.git 

2. 查看其中的 angularjs.html ,把里面的 JS ,CSS 都抓过来。 记得其中的 JS 需要在页面底部,例如:

199 <script src="js/jquery.fileupload-video.js"></script>
200 <!-- The File Upload validation plugin -->
201 <script src="js/jquery.fileupload-validate.js"></script>
202 <!-- The File Upload Angular JS module -->
203 <script src="js/jquery.fileupload-angular.js"></script>
204 <!-- The main application script -->
205 <script src="js/app.js"></script>
206 </body>

3. 修改对应的CSS 文件,里面有两处的图片需要修改。 

4. 修改app.js ,注册使用 formatFileSizeFilterProvider 

5. 我用的是angular js, 需要3个部分 

    5.1 把config 加上去 

    5.2 把controllers 加上去。

    5.3 修改 main.js

注意: 其中添加的JS顺序一定要跟DEMO 中的一模一样!!!

而且要放在页面的下方。 <body>标签的最下面!!!!!

最后,是客户端,处理如何上传。

jquery upload 的上传回调函数

done

Callback for successful upload requests. This callback is the equivalent to the success callback provided by jQuery ajax() and will also be called if the server returns a JSON response with an error property.

function (e, data) {
// data.result
// data.textStatus;
// data.jqXHR;
}

Back