zoukankan      html  css  js  c++  java
  • jQuery file upload 服务端返回数据格式

    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.

  • 相关阅读:
    BZOJ-2431: [HAOI2009]逆序对数列 (傻逼递推)
    BZOJ3695 滑行
    BZOJ3689 异或之
    BZOJ3696 化合物
    BZOJ1393 [Ceoi2008]knights
    BZOJ2280 [Poi2011]Plot
    BZOJ1570 [JSOI2008]Blue Mary的旅行
    BZOJ2751 [HAOI2012]容易题(easy)
    BZOJ2818 Gcd
    BZOJ2426 [HAOI2010]工厂选址
  • 原文地址:https://www.cnblogs.com/chucklu/p/11171866.html
Copyright © 2011-2022 走看看