[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.
Chinese name files uploaded using FTP can be displayed normally.
There is no problem with the Chinese characters in the content of thefile!
[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>