Page 1 of 1

upload / download files with accent in file name

PostPosted: 27. April 2011 13:39
by duibia
Hi all,
I have a problem in dowload files with

Server Description:
- XAMPP for Linux 1.7.3a
- Linux svnserveretms 2.6.9-89.ELsmp #1 SMP Mon Apr 20 10:34:33 EDT 2009 i686 i686 i386 GNU/Linux
- Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
- phpinfo() LANG=en_US.UTF-8

Functional description: users can upload files to share with other users (there is an upload page and then a download page with all the uplaoded files and the relative links)
Once uploaded I save the filename in the DB and put the file in a directory.

The problem arise when I upload files with file name containing characters with accent (e.g. "Studio_fattibilità_NA.PDF").
The upload goes right but when I try to download the file, xammp returns the following error:

File does not exist: /opt/lampp/htdocs/gestionale/allegati/357/Studio_fattibilit\xc3\xa0_NA.PDF, referer: http://192.168.99.252/gestionale/gestio ... hp?ida=357

but the file exist:

[root@svnserveretms 357]# ll /opt/lampp/htdocs/gestionale/allegati/357/
-rw-r--r-- 1 nobody nobody 1302824 Jan 31 17:55 Studio_fattibilità_NA.PDF

looking at the error, it seems that the "à" is coded as "\xc3\xa0"

who can help me?

thanks

Re: upload / download files with accent in file name

PostPosted: 27. April 2011 18:17
by WilliL
I decided for me, to rename uploaded files [a-z,0-9,-,_].ext
My database contains: upload_id (unique), upload_file, upload_comment, upload_user, upload_timestamp
Users can upload files and comments.
You could use the "upload name" in another row in your database, and rename the file with easy chars.
On downloads you could use the upload name in your php-script:
Code: Select all
// complete headers
header("Content-Disposition: attachment; filename=\"$save_as_name\"");

(tested with download as "1ÄÖÜéî.jpg" filename "test.jpg"