Save Files that containing Files Name with Different Characters using PHP
I am trying to upload files using php. Uploading is working. But i have a file which contain file name (not content) with different language. (ex. japaneese characters). But after i upload that file to server; file name showing with different characters. How do i upload Sa开发者_JAVA技巧me file name to the Server.
Sounds like you've got a character encoding problem. You'll have to make sure your HTML form and your PHP configuration use the same character set. UTF-8 is the preferred one since it contains characters from almost all widely spoken languages. Your Form tag should include an attribute like so:
<form accept-charset="UTF-8" ...>
Also, check that your php.ini
file specifies the default character set:
default_charset = "UTF-8"
If you can't control what's in your php.ini
, you could try putting it in your .htaccess
file (assuming a typical Apache server.) Like so:
php_value default_charset UTF-8
For good measure, you can also add a Content-Type meta tag into your HTML header section specifying UTF-8:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
If you're storing any filenames in a database, you'll have to make sure that it too is using UTF-8.
精彩评论