Implementation Mode of file upload/download between http-android/iOS client and restapi developed by PHP

Source: Internet
Author: User
For example, Sina Weibo's APi for uploading images and sending messages also works in this mode. The parameter keywords are encapsulated in json and uploaded to the php server for processing, the file transfer function is not clear. I checked the information and said there are several types. One is to directly convert the image into two...

For example, Sina Weibo's APi for uploading images and sending messages also works in this mode. The parameter keywords are encapsulated in json and uploaded to the php server for processing, the file transfer function is not clear. I checked the information and said there are several types. One is to directly convert the image into a binary string and then serialize and deserialize the image. The other one is to use multipart/form-data for transmission. I don't quite understand that the transmission should be both json and file transfer. How can I encapsulate the data on the client, what does the php server do? Of course, it is no problem to upload json files or files separately.

Reply content:

For example, Sina Weibo's APi for uploading images and sending messages also works in this mode. The parameter keywords are encapsulated in json and uploaded to the php server for processing, the file transfer function is not clear. I checked the information and said there are several types. One is to directly convert the image into a binary string and then serialize and deserialize the image. The other one is to use multipart/form-data for transmission. I don't quite understand that the transmission should be both json and file transfer. How can I encapsulate the data on the client, what does the php server do? Of course, it is no problem to upload json files or files separately.

This interface is described in the documentMultipart/form-dataSubmit. You are not required to upload another json image. This interface does not use JSON.

If you use your method with JSON and files, JSON is treated as a common string, but this string is in JSON format. Then the interface will be changed to only two fields: json (described in this document) and pic, and the format of json fields is also specified.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.