Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

HttpClient not support upload file with chinese name #41249

Copy link
Copy link
Closed
@krissss

Description

@krissss
Issue body actions

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.