ISO-8859-1至UTF-8

时间:2017-01-24 08:59:17

标签: php character-encoding upload mb-convert-encoding

上传的英文文件没有任何问题,但如果我上传utf-8格式文件的格式,我将会出现如下错误:无法打开流:无效的参数。
$file正在工作。所以我不认为改变格式是个问题。我不知道问题是什么。天才,请帮助我。谢谢。


我发现iconv function :: // ignore change -c选项。右..?

echo "==>".var_dump(iconv_get_encoding('all'))."<br>"; // result: 'ISO-8859-1'

//$fileName = iconv("utf-8", "ISO-8859-1", $_FILES['csv_file']['name']);
$file = mb_convert_encoding($_FILES['csv_file']['name'],"utf-8", "utf-8");
$file = basename($file);

echo "\nfile name:  ".$file; // result: utf-8 format working

if(is_uploaded_file($_FILES["csv_file"]["tmp_name"])) {
    $target_path =  $_SERVER['DOCUMENT_ROOT'] . "/upload/".$file; //basename($_FILES['csv_file']['name']);
    move_uploaded_file($_FILES['csv_file']['tmp_name'], $target_path);
}
echo $target_path; //result: C:/APM_Setup/htdocs/upload/filename.txt

0 个答案:

没有答案