Post files received by php

Source: Internet
Author: User
Tags php server
The vc client uses the http post abc.txt file to send the post file to the php server. the abc.txt file received by the server is empty. Is it a php: // input problem. Thank you!

Vc client:
Content-Disposition: form-data; name = "upload"; filename = "abc.txt"
Content-Type: text/plain


Php server:
$ Input = file_get_contents ('php: // input ');
File_put_contents('abc.txt ', $ input );
?>


Reply to discussion (solution)

Use $ _ FILE to receive parameters.

To upload a file, use enctype = "multipart/form-data"
Php: // input does not accept such data, but the original post data (raw)

As you can see in the manual,
Php: // input is a read-only stream that can access the requested raw data. In the case of POST requests, it is best to use php: // input instead of $ HTTP_RAW_POST_DATA, because it does not rely on specific php. ini commands. In this case, $ HTTP_RAW_POST_DATA is not filled by default, which requires less memory than activating always_populate_raw_post_data. When enctype = "multipart/form-data", php: // input is invalid.

After checking the manual, php: // input is invalid when enctype = "multipart/form-data". use $ _ FILES. Thank you!

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.