https://blog.csdn.net/huangjingwen1129/article/details/82858573 关于php://input、$_POST、$HTTP_RAW_POST_DATA的理解及区别
$HTTP_RAW_POST_DATA是一个全局获取post数据的参数,php7之后已经弃用
项目中遇到一个php文件如下
$open1 = $default_path . basename( $_GET[ 'name' ] );
$jfh = fopen($open1, 'w') or die("fail");
fwrite($jfh, $HTTP_RAW_POST_DATA);
fclose($jfh);
正常来讲 直接访问这个链接 如http://xx.com/ok_up.php?name=cmd.txt,会产生cmd.txt文件 内容为空
如果添加post内容,默认会写入cmd.txt失败。因为php post默认的content_type是application/x-www.form-urlencoded,或者当
enctype="multipart/form-data"时也无法使用
$HTTP_RAW_POST_DATA这个参数如果在php.ini的always_populate_raw_post_data为ON时候直接生效
但是默认是off状态。
需要把post包里的application/x-www.form-urlencoded改为text/xml或application/json,soap (
application/soap+xml
),上传参数$HTTP_RAW_POST_DATA即可生效