php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25004 Uploaded file name truncated if accent present
Submitted: 2003-08-10 10:54 UTC Modified: 2004-08-08 15:01 UTC
From: spud at nothingness dot org Assigned:
Status: Not a bug Package: *Languages/Translation
PHP Version: 4.3.2 OS: RedHat 7.2
Private report: No CVE-ID: None
 [2003-08-10 10:54 UTC] spud at nothingness dot org
Description:
------------
On a standard form upload, if the user uploads a file 
with a name like "?pice.jpg" (with an acute accent on 
the e), PHP reports the $_FILES[0]['name'] as "foo_e", 
dropping the accent and ALL following characters, 
including the suffix.

I understand the perhaps the file upload can't handle 
the accented characters, but it seems incorrect to 
strip off the rest of the filename, including 
characters that are still legitimate.

I don't know if this is a PHP bug or not, but it seems 
very limiting for non-English file uploads, where 
accented characters in a filename are common.

Reproduce code:
---------------
Example: with a page like

<html>
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body>
<form action="test.php" method="post" enctype="multipart/form-data">
<input type="file" name="upload">
<input type="submit" name="submit" value="submit">
</form>

<?
if (isset($_POST['submit'])) {
	print_r($_FILES);
}
?>

upload a file named "?pice.jpg", and PHP will report the filename as "e".

Expected result:
----------------
I expect $_FILES[0]['name'] to be "?pice.jpg", or at 
least "epice.jpg".

Actual result:
--------------
Filename reported as "e".

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-08-10 11:11 UTC] sniper@php.net
Works fine with latest CVS (and with PHP 4.3.3RC3 too)
Bogusing since you failed the first rule of submitting a bug report: Try the latest CVS snapshot first.

 [2003-08-11 11:27 UTC] spud at nothingness dot org
Actually, the first rule of submitting a bug is "check 
the database first", but point taken.

This problem still occurs with PHP 4.3.3RC3 on my 
machine, despite your results. See (http://
dev.dadaimc.org/test.php for test form and phpinfo() 
output)

The CVS snapshot (php4-200308111530) refuses to make on 
my machine, generating an error near the end (see 
below), so I can't test the CVS version:

/home/spud/src/php4-200308111530/ext/standard/
filestat.c:575: undefined reference to 
`php_check_open_basedir_ex'
 [2003-08-11 11:34 UTC] spud at nothingness dot org
Correction: the problem persists in PHP 4.3.3RC3 with 
the (mac) Safari browser, but works in (mac) IE 5.2.3. 
Until further browser testing, I'll consider this 
"bogus", assuming it's a browser issue with Safari 
only.
 [2004-08-08 15:01 UTC] magnus@php.net
Restore comment: 
[2004-07-23 21:12:44] apinstein at mac dot com 
 
Actually, it seems that Safari has a problem uploading  
files with non-latin filenames. In Safari 1.2 (Panther)  
the file is SKIPPED entirely from the upload's POST  
data. In Safari pre-1.2, (Jaguar) the filename is  
mangled a bit. 
 
I am pretty sure this isn't a PHP problem, but if anyone  
knows how to set up the HTML form to allow this it'd be  
great for everyone to know! 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 14:01:28 2024 UTC