Reputation: 99
The files in English are uploaded without any problem, but if I upload the format of a utf-8 format file, I will have an error like this: failed to open stream: Invalid argument.
$file
working. So I don't think it's a problem to change the format. I don't know what the problem is. Genius, Please help me. Thank you.
And I found iconv function :: //ignore change -c option. right..?
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
Upvotes: 1
Views: 153