Objective-c-IOS uses ASIHttpRequest to send to PHP. How does PHP receive images?

Source: Internet
Author: User
How does php receive images uploaded to the web by iOSapp? Before receiving a file, you need to determine whether to upload the file. Control the size of the uploaded file {code ...} judge by definition {code ...} determine whether there is a value {code ...} but there is a big problem... how does php receive images uploaded to the web on iOS app?
Before receiving a file, you need to determine whether to upload the file.

Control the size of uploaded files

$_FILES["file"]["size"]

Determined by definition or not

isset($_POST['file'])

Determine whether there is a value

empty(file_get_contents("php://input")

However, there is a big problem currently. If you have set the judgment, you will not be able to upload the file.
If the file is directly uploaded without adding any conditions, the file will be uploaded successfully.

move_uploaded_file($_FILES["file"]["tmp_name"],     "./img/" . $_FILES["file"]["name"]);

How do I receive files sent via ASI?
Does he have a key value?
Is the forkey in the following statement a key?

[request setPostValue:@"" forKey:@"file"];

Reply content:

How does php receive images uploaded to the web on iOS app?
Before receiving a file, you need to determine whether to upload the file.

Control the size of uploaded files

$_FILES["file"]["size"]

Determined by definition or not

isset($_POST['file'])

Determine whether there is a value

empty(file_get_contents("php://input")

However, there is a big problem currently. If you have set the judgment, you will not be able to upload the file.
If the file is directly uploaded without adding any conditions, the file will be uploaded successfully.

move_uploaded_file($_FILES["file"]["tmp_name"],     "./img/" . $_FILES["file"]["name"]);

How do I receive files sent via ASI?
Does he have a key value?
Is the forkey in the following statement a key?

[request setPostValue:@"" forKey:@"file"];

The PHP program is executed only after the file is uploaded. That is to say, you cannot use the PHP program to determine and block the file upload, because the file has been uploaded to the server when the program is running.

You only need to let the client first pass the basic information of the file to be uploaded to another PHP program, the program determines whether the file is allowed to be uploaded through the information, and then upload the image through this address.

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.