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.

  • 相关阅读:
    作业八
    作业七:用户体验设计案例分析
    作业六。合作编程
    作业五:需求分析
    作业四:结对编程2
    作业四:合作
    作业三:词频统计
    学习进度表
    java程序练习
    简单博客练习
  • 原文地址:https://www.cnblogs.com/chucklu/p/11171866.html
Copyright © 2011-2022 走看看