|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-06-11 08:26 UTC] clark at electrobeat dot dk
[2018-06-11 09:07 UTC] requinix@php.net
-Type: Bug
+Type: Feature/Change Request
[2018-06-11 09:07 UTC] requinix@php.net
[2018-06-11 09:28 UTC] clark at electrobeat dot dk
[2018-06-11 09:29 UTC] clark at electrobeat dot dk
[2018-06-11 09:59 UTC] requinix@php.net
[2021-07-27 12:05 UTC] cmb@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
Description: ------------ It's not possible to read the request stream from multipart/form-data requets $body = file_get_contents('php://input'); It seems like it has been a open bug for many years so I don't get why it has never been fixed!? If a user uploads a file you can't even check if the data part is gzipped or anything.. It doesn't make sense that you only can read streams from some request streams but not from others!? Test script: --------------- $boundary = 'jlasdifj439'; $field1 = json_encode(['test' => 123]); $body = '--'.$boundary."\r\n" .'Content-Disposition: form-data; name="json"; filename="file.pdf"'."\r\n" .'Content-Type: application/json'."\r\n" .'Content-Length: '.strlen($field1)."\r\n\r\n" .$field1."\r\n" .'--'.$boundary.'--'; $socket = curl_init(); curl_setopt_array($socket, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_VERBOSE => true, CURLOPT_ENCODING => '', CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0, ]); curl_setopt($socket, CURLOPT_URL, 'https://api-scan.dynaccount.com/'); curl_setopt($socket, CURLOPT_HTTPHEADER, [ 'Content-Type: multipart/form-data; boundary='.$boundary, ]); curl_setopt($socket, CURLOPT_POSTFIELDS, $body); if(!$response = curl_exec($socket)){ echo "ERROR!"; } echo $response;