Objective-c-iOS uses asihttprequest send to php,php how do I receive pictures?

Source: Internet
Author: User
IOS app side upload image to web,php how to receive?
Before receiving, you need to make a decision to control whether the file is given upload.

Size control by uploading files

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

By whether or not you have defined the judgment

isset($_POST['file'])

Determine if there is a value

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

However, there is a big problem, if you have set a judgment, you will not be able to upload.
If you do not add conditions directly to the upload, the file will be uploaded successfully.

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

So how do I receive a file sent over by ASI?
Does he exist with a key value?
Is the Forkey in the following statement a key?

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

Reply content:

IOS app side upload image to web,php how to receive?
Before receiving, you need to make a decision to control whether the file is given upload.

Size control by uploading files

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

By whether or not you have defined the judgment

isset($_POST['file'])

Determine if there is a value

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

However, there is a big problem, if you have set a judgment, you will not be able to upload.
If you do not add conditions directly to the upload, the file will be uploaded successfully.

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

So how do I receive a file sent over by ASI?
Does he exist with a key value?
Is the Forkey in the following statement a key?

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

PHP program is done after the file upload is completed, that is, you can not use the PHP program to judge and prevent the file upload, because the program is running when the file has been uploaded to the server.

Your need only is to let the client first to upload the basic information of the file to another PHP program, the program through the information to determine whether the file is allowed to upload, and then upload pictures 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.