Closed
Description
Symfony version(s) affected: 4.4.13
Description
HttpClient upload file with chinese name, but server cannot accept it.
How to reproduce
client:
$client = HttpClient::create();
$formData = new FormDataPart([
'files' => DataPart::fromPath(__DIR__ . '/中文.txt')
]);
$response = $client->request('POST', 'http://localhost/test/fileupload.php', [
'headers' => $formData->getPreparedHeaders()->toArray(),
'body' => $formData->bodyToIterable(),
]);
dd($response->getContent(false));
server:
var_dump($_FILES);
The right result should have $_FILES
, but no.
Possible Solution
I log formData info use this: file_put_contents(__DIR__ . '/a.txt', $formData->toString());
, and get
Content-Type: multipart/form-data; boundary=RGWgOk4l
--RGWgOk4l
Content-Type: text/plain
Content-Transfer-Encoding: 8bit
Content-Disposition: form-data; name="files"; filename*=utf-8''"%E4%B8%AD%E6%96%87.txt"
中文
--RGWgOk4l--
When I change
Content-Disposition: form-data; name="files"; filename*=utf-8''"%E4%B8%AD%E6%96%87.txt"
to Content-Disposition: form-data; name="files"; filename="中文.txt"
or Content-Disposition: form-data; name="files"; filename="中文.txt"; filename*=utf-8''"%E4%B8%AD%E6%96%87.txt"
It correct uploaded!
But I dont known how to fix this
Additional context