Home  >  Article  >  Backend Development  >  Why can't $_REQUEST and $_POST get parameters?

Why can't $_REQUEST and $_POST get parameters?

WBOY
WBOYOriginal
2016-08-18 09:15:302029browse

The mobile terminal converts the image into hexadecimal, and then posts it to the server (php). I use $_REQUEST['image'] to accept it.

var_dump( $_REQUEST['image'] ) can be output, a very large string, but both !isset( $_REQUEST['image'] and empty( $_REQUEST['image'] are judged is true, and the return value of the file_put_content( $file_path, $_REQUEST['image']) function is

.

$_REQUEST['image'] is 0000 00080002 01120003 00000001 00010000 87690004 00000001 00000026 00000000 0002a002 00040000 00010000 10c0a003 00040000 00 010000 0b200000 0000ffed 00385068 6f746f73 686f7020 332e3000 3842494d 04040000 00000000 3842494d 04250000 00000010 d41d8cd9 8f00b204 e9800998 ecf8427e ffe20240 494343......
Like this

Reply content:

The mobile terminal converts the image into hexadecimal, and then posts it to the server (php). I use $_REQUEST['image'] to accept it.

var_dump( $_REQUEST['image'] )

can be output, a very large string, but both !isset( $_REQUEST['image'] and empty( $_REQUEST['image'] are judged is true, and the return value of the file_put_content( $file_path, $_REQUEST['image']) function is .

$_REQUEST['image']

is 0000 00080002 01120003 00000001 00010000 87690004 00000001 00000026 00000000 0002a002 00040000 00010000 10c0a003 00040000 00 010000 0b200000 0000ffed 00385068 6f746f73 686f7020 332e3000 3842494d 04040000 00000000 3842494d 04250000 00000010 d41d8cd9 8f00b204 e9800998 ecf8427e ffe20240 494343......Like this
Let the mobile terminal base64

encode the binary image and POST it.

php processing code

<code>$data = $_POST['image'];
$bin = base64_decode($data);
file_put_contents(__DIR__.'/a.jpg',$bin);</code>
Try $_FILES['image']
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn