Use PHP to receive uploaded files, and the Chinese part of the file name is displayed as a question mark on the server side.

[solution] add

to the front-end code as prompted by Derek_Chen
<meta charset="gbk">
The display is normal after

!

< hr >

[problems encountered]

attempted to receive the uploaded file using PHP, and the file was received successfully, but the Chinese part of the file name always appears as a question mark on the server side.

PHP

Chinese name files uploaded using FTP can be displayed normally.

There is no problem with the Chinese characters in the content of the

file!

[attempts made]

I judged that it should be a coding problem, but I used--

respectively.
iconv("UTF-8","gbk",$_FILES["userfile"]["name"])
iconv("UTF-8","gb2312",$_FILES["userfile"]["name"])
iconv("gbk","UTF-8",$_FILES["userfile"]["name"])
iconv("gb2312","UTF-8",$_FILES["userfile"]["name"])

were not successful.

also try to save the uploaded file as "UTF-8" code first, and the result is the same!

[Test Environment]

server
Host type: Ali Cloud Virtual Host
operating system: CentOS 6.564-bit
PHP version: PHP5.5

client
operating system: Windows 10 Family Chinese version 1803

[related Code]

upload.html (upload)

<html>
<head>
<title>Administration - upload new files</title>
</head>
<body>
<h1>Upload new news files</h1>
<form action="upload.php" method="post" enctype="multipart/form-data">
  <div>
    <input type="hidden" name="MAX_FILE_SIZE" value="1000000"/>
    <label for="userfile">Upload a file:</label>
    <input type="file" name="userfile" id="userfile"/>
    <input type="submit" value="Send File"/>
  </div>
</form>
</body>
</html>

upload.php (receive)

<html>
<head>
<title>Uploading...</title>
</head>
<body>
<h1>Uploading file...</h1>
<?php
$filename=iconv("UTF-8","gbk",$_FILES["userfile"]["name"]);
$upfile="../uploads/".$filename;
if(is_uploaded_file($_FILES["userfile"]["tmp_name"])){
  if(!move_uploaded_file($_FILES["userfile"]["tmp_name"],$upfile)){
    echo "Problem:Could not move file to destination directory.";
    exit;      
  }
}else{
  echo "Problem:Possible file upload attack.Filename:".$filename;
  exit;  
}
echo "File uploaded successfully.<br/><br/>";
?>
</body>
</html>
Mar.14,2021

according to your code, it is recommended to try the following method
1, the php backend of the form submission, and add

to the first line.
header("Content-Type:text/html;charset=utf-8");

2. Add the following to < head > < / head > in the html of the front end

<meta charset="UTF-8">

after adding the above two parts, cancel the relevant iconv () conversion function test first, and then add the relevant description in the comments if there are any questions.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e489b4-59250.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e489b4-59250.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?