码迷,mamicode.com
首页 > Web开发 > 详细

jQuery file upload 服务端返回数据格式

时间:2019-07-11 18:51:47      阅读:148      评论:0      收藏:0      [点我收藏+]

标签:using   end   type   github   out   direct   格式   ace   成功   

Using jQuery File Upload (UI version) with a custom server-side upload handler

正常的返回结果,即上传文件成功

Extend your custom server-side upload handler to return a JSON response akin to the following output:

{"files": [
  {
    "name": "picture1.jpg",
    "size": 902604,
    "url": "http:\/\/example.org\/files\/picture1.jpg",
    "thumbnailUrl": "http:\/\/example.org\/files\/thumbnail\/picture1.jpg",
    "deleteUrl": "http:\/\/example.org\/files\/picture1.jpg",
    "deleteType": "DELETE"
  },
  {
    "name": "picture2.jpg",
    "size": 841946,
    "url": "http:\/\/example.org\/files\/picture2.jpg",
    "thumbnailUrl": "http:\/\/example.org\/files\/thumbnail\/picture2.jpg",
    "deleteUrl": "http:\/\/example.org\/files\/picture2.jpg",
    "deleteType": "DELETE"
  }
]}

上传失败,出现错误

To return errors to the UI, just add an error property to the individual file objects:

{"files": [
  {
    "name": "picture1.jpg",
    "size": 902604,
    "error": "Filetype not allowed"
  },
  {
    "name": "picture2.jpg",
    "size": 841946,
    "error": "Filetype not allowed"
  }
]}

删除文件

When removing files using the delete button, the response should be like this:

{"files": [
  {
    "picture1.jpg": true
  },
  {
    "picture2.jpg": true
  }
]}

 

Note that the response should always be a JSON object containing a files array even if only one file is uploaded.

Visit the uploaded directory - you should see the same file upload interface as in the demo, allowing you to upload files to your website.

 

jQuery file upload 服务端返回数据格式

标签:using   end   type   github   out   direct   格式   ace   成功   

原文地址:https://www.cnblogs.com/chucklu/p/11171866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!