Thinkphp cannot receive images from ios post, and can only accept text! How can this problem be solved?

Source: Internet
Author: User
{Code...} How can I write it now to know whether the image has been post?
$ Upload = new \ Think \ Upload (); // instantiate the upload class $ upload-> maxSize = 3145728; // set the attachment upload size $ upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg '); // $ upload-> savePath = '/Public/Uploads/images/'; $ info = $ upload-> upload (); if (! $ Info) {// upload error message $ this-> error ($ upload-> getError ());}

How can I write it now to know whether the image has been post?

Reply content:
$ Upload = new \ Think \ Upload (); // instantiate the upload class $ upload-> maxSize = 3145728; // set the attachment upload size $ upload-> exts = array ('jpg ', 'gif', 'png', 'jpeg '); // $ upload-> savePath = '/Public/Uploads/images/'; $ info = $ upload-> upload (); if (! $ Info) {// upload error message $ this-> error ($ upload-> getError ());}

How can I write it now to know whether the image has been post?

In this case, you need to communicate with iOS. If the other party sends the native NSData, it should be in hexadecimal format like this:


  

Then let him use base64, and then send it, you will receive it as a string, then the string operation will start and end with a hexadecimal content, and then convert the content to binary using the built-in function, finally, use the Write File function to save the binary stream as an image.

Of course, if iOS can use a third party to send binary messages directly, that's all fun (-.-;)

Communication is the most important thing !!!

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.