|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70794 Implement RFC 2231 for handling filenames in uploads
Submitted: 2015-10-26 15:20 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: viskoo at gmail dot com Assigned:
Status: Open Package: HTTP related
PHP Version: 5.6.14 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-10-26 15:20 UTC] viskoo at gmail dot com
The aforementioned RFC deals with how to encode filenames when sending files as part of a POST request. If PHP receives a request from a client that implements this RFC, and the filename has special characters, the uploaded files will be lost ($_FILES will be empty), and a warning will be produced:

PHP Warning:  File Upload Mime headers garbled in Unknown on line 0

It doesn't matter if you put Apache, or nginx in front of PHP, or use the built in webserver.

Test script:
Create an index.php file:


header('content-type', 'application/json');
echo json_encode($_FILES);

Launch the webserver with php -S localhost:9000.

Use this python script that uses the requests library to make an RFC 2231 compliant request:

import requests

filename = 'fårikål.txt'
destination = 'http://localhost:9000'
files = { filename: 'hello world' }

res =, files=files)
print(res.status_code, res.text)

Expected result:
  "får": {
    "name": "får.txt",
    "type": "text/plain",
    "tmp_name": "/tmp/phpuXCXkF",
    "error": 0,
    "size": 12

Actual result:
200 []

(empty result due to the warning, and status code 200)


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Wed Dec 06 02:01:27 2023 UTC