php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77262 curl_file_create() failed with unicode filenames
Submitted: 2018-12-07 13:52 UTC Modified: 2018-12-08 01:09 UTC
From: sh-ya at ya dot ru Assigned:
Status: Not a bug Package: cURL related
PHP Version: 7.3.0 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sh-ya at ya dot ru
New email:
PHP Version: OS:

 

 [2018-12-07 13:52 UTC] sh-ya at ya dot ru
Description:
------------
cURL cannot upload files with filenames containing unicode characters.
5.6.38, 7.0.32: upload is successful
7.1.25, 7.2.13, 7.3.0: upload failed

Test script:
---------------
$test_file = sys_get_temp_dir() . DIRECTORY_SEPARATOR
    . '✄♚♛♜♞PHP' . PHP_VERSION . PHP_OS . '.txt';
file_put_contents($test_file, 'test') or exit('file_put_contents failed');
register_shutdown_function(function() use ($test_file) {
    unlink($test_file); 
});
$curl = curl_init('http://localhost/upload.php');
curl_setopt_array($curl, [
    CURLOPT_POST => TRUE,
    CURLOPT_SAFE_UPLOAD => TRUE,
    CURLOPT_POSTFIELDS => ['file' => curl_file_create($test_file)],
    CURLOPT_RETURNTRANSFER => TRUE,
    CURLOPT_HEADER => TRUE
]);
$got = curl_exec($curl);
var_dump($got, curl_error($curl), curl_getinfo($curl), PHP_VERSION);

----------------
upload.php:
---
var_dump($_FILES);



Expected result:
----------------
HTTP/1.1 200 OK
Date: Fri, 07 Dec 2018 13:40:12 GMT
Server: Apache
Vary: Accept-Encoding
Content-Length: 284
Content-Type: text/html; charset=utf-8

array(1) {
  ["file"]=>
  array(5) {
    ["name"]=>
    string(33) "✄♚♛♜♞PHP7.3.0WINNT.txt"
    ["type"]=>
    string(24) "application/octet-stream"
    ["tmp_name"]=>
    string(29) "D:\TMP\php8BF9.tmp"
    ["error"]=>
    int(0)
    ["size"]=>
    int(4)
  }
}


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-12-08 01:09 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2018-12-08 01:09 UTC] ab@php.net
Thanks for the report. The libcurl API is what is responsible for this behavior, as it doesn't seem to support UNICODE Windows API. Please report this issue to the cURL project.

Thanks.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 07 19:01:24 2019 UTC