zoukankan      html  css  js  c++  java
  • php move_uploaded_file 上传的文件移动带中文文件名的的问题

    错误如下:

    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:WINDOWSTempphp80.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"));
    
  • 相关阅读:
    对deferred(延迟对象)的理解
    string 、char* 、 char []的转换
    char* 和 cha[]
    层序遍历二叉树
    之字形打印二叉树
    右值
    函数指针(待修改)
    top k

    哈夫曼编码
  • 原文地址:https://www.cnblogs.com/makalochen/p/12837021.html
Copyright © 2011-2022 走看看