Php obtains multipart/form

Source: Internet
Author: User
Blog. csdn. netgold2008articledetails8496489 uses php as a forwarding program. It forwards all the data received from the browser to another url for processing. GET and POST operations are normal, but when uploading images, it is found that the upload fails. Check the information and find out. Php: input, $ HTTP_RAW _

Http://blog.csdn.net/gold2008/article/details/8496489 with php to do a forwarding program, is from the browser to receive what data, the complete forwarding to another url for processing, GET, POST are normal, but when uploading images, it is found that the upload fails. Check the information and find out. Php: // input, $ HTTP_RAW _

Http://blog.csdn.net/gold2008/article/details/8496489


Using php as a forwarding program, the system forwards all the data received from the browser to another url for processing. GET and POST operations are normal, but when uploading images, it is found that the upload fails. Check the information and find out.

Php: // input, $ HTTP_RAW_POST_DATA cannot be used for enctype = "multipart/form-data". Because php will try to parse the received data and put it into $ _ POST after parsing, $ _ GET array, which cannot be parsed, is placed in php: // input.

In apache, the Content-Type is manually changed from multipart/form-data to another name, so that php will not parse POST data. The http://stackoverflow.com/questions/1361673/get-raw-post-data man shared his approach.

In apache, add the following to the. htaccess file:

SetEnvIf Content-Type ^ (multipart/form-data) (. *) MULTIPART_CTYPE = $1 $2
RequestHeader set Content-Type application/x-httpd-php env = MULTIPART_CTYPE

Then, in the php program, you can use file_get_contents ('php: // input'); to obtain the original data. Then, the data can be sent out.

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.