I'm Vietnamese and i want to upload a utf-8 filename like
Tên Tệp Tiếng Việt.JPG
Here is my code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>utf-8</title> </head> <body> <?php if(isset($_POST["submit"])) { if($_FILES["upload"]["error"] > 0 ) echo "FILE ERROR!"; else { $base_dir = "D:/"; $fn = $_FILES["upload"]["name"]; $fn2 = $base_dir.$fn; move_uploaded_file($_FILES["upload"]["tmp_name"],$fn2); } } ?> <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> <input type="file" name="upload" id="upload" /> <input type="submit" name="submit" id="submit" value="Send" /> </form> </body> </html> but when i upload that i see on my computer D:\ has a file like
Tên Tệp Tiếng Việt.JPG
How to fix that thanks
UTF-8' toucs2' is not allowed ?UCS-2actually :)move_uploaded_file(): Filename cannot be empty ..andmove_uploaded_file(): Unable to move 'E:\PHP\Xampp\tmp\php6B2C.tmp' ...? what is wrongechothe filename you receive on the server? Test whether the filename is uploaded encoded in UTF-8? Because that part is likely working. The problem is how PHP interacts with the file system when writing files, which basically depends on whatever the underlying filesystem does, which may be pretty ugly and complex in case of Windows. If the filename is uploaded fine in UTF-8 the question becomes "how to write a filename in UTF-8", the answer to which may not be pretty.