错误如下:

Warning: move_uploaded_file(xxx.gif) [function.move-uploaded-file]: faild to open stream : Invalid atgument in xxx line 25
Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php80.tmp' to xxx' in xxx line 25

并且文件移动失败!

原因:

php字符编码和windows不同的问题,简体中文版的windows对文件名的命名一般使用gbk或gb2312编码。而php中的非ASCII字符串变量的值大多使用utf8编码(当然,这个默认值可以修改。。),所以在处理带中文的路径的时候需要转码

处理方法

例:

move_uploaded_file($_FILES["file"]["tmp_name"],"./upload/" . $_FILES["file"]["name"]);
改成
move_uploaded_file($_FILES["file"]["tmp_name"],"./upload/" . mb_convert_encoding($_FILES["file"]["name"],"gbk", "utf-8"));

相关文章:

  • 2021-07-27
  • 2022-02-27
  • 2021-06-29
  • 2021-07-13
  • 2021-11-11
  • 2022-12-23
  • 2021-10-19
猜你喜欢
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
相关资源
相似解决方案