Req #76444 [Opn]: can't read stream from multipart requests
| From: | clark at electrobeat dot dk | Date: | Mon, 11 Jun 2018 09:29:02 +0000 |
| Subject: | Req #76444 [Opn]: can't read stream from multipart requests | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215602@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76444&edit=1
ID: 76444
User updated by: clark at electrobeat dot dk
Reported by: clark at electrobeat dot dk
Summary: can't read stream from multipart requests
Status: Open
Type: Feature/Change Request
Package: Streams related
Operating System: debian stretch
PHP Version: 7.0.30
Block user comment: N
Private report: N
New Comment:
could anyone please remove the URL in the description to my server..
Previous Comments:
------------------------------------------------------------------------
[2018-06-11 09:28:19] clark at electrobeat dot dk
Is it possible to get the headers from the parts of a multipart request?
------------------------------------------------------------------------
[2018-06-11 09:07:37] requinix@php.net
It hasn't been fixed because it isn't a bug.
http://php.net/manual/en/wrappers.php.php
> php://input is not available with enctype="multipart/form-data".
File upload requests are often large. They can't necessarily be buffered to memory, though
buffering to a temp file would probably be a reasonable fallback. And obviously being a data stream
so it's not naturally seekable.
But it sounds like what you really want is to get the multipart headers. AFAIK that's a brand
new idea.
------------------------------------------------------------------------
[2018-06-11 08:26:00] clark at electrobeat dot dk
want to delete the url to my server
------------------------------------------------------------------------
[2018-06-11 08:23:57] clark at electrobeat dot dk
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;
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76444&edit=1