【问题标题】:php: Warning: rename The filename, directory name, or volume label syntax is incorrect. (code: 123)php: 警告:重命名文件名、目录名或卷标语法不正确。 (代码:123)
【发布时间】:2015-05-17 04:59:48
【问题描述】:

由于我试图复制我的文件,我收到此错误,我使用的是 Windows 8.1

警告:重命名(../user/will/video/javascript-toggle-buttons-MonMar09122015-7491.mp4,../user/will/video/video-SunMar-15-18:03-2015-shared .mp4):文件名、目录名或卷标语法不正确。 (代码:123)在 E:\xampp\htdocs\social_media\root\php_parsers\status_system.php 第 353 行

这是我想做的,

if (file_exists("../user/$author/$folder/$file")) {
    if (!file_exists("../user/$account_name/$folder")){
        mkdir("../user/$account_name/$folder/",0755);
    }
    copy("../user/$author/$folder/$file","../user/$account_name/$folder/$file");
    $dbnewFile = $newFileName.'.'.$fileExt;
    // for rename purpose
    $oldName = "../user/$account_name/$folder/$file";
    $newName = "../user/$account_name/$folder/$dbnewFile";
    rename($oldName, $newName);
}

这有什么问题?我厌倦了看到这个错误:(真的很沮丧。

【问题讨论】:

  • 警告信息表明问题出在第 353 行。为我们标记这些行,以便我们知道哪一行是 353。问题可能是您使用 !file_exists() 检查目录,而不是文件。
  • 第 353 行是 rename($oldName, $newName); 和我的 !file_exists() 工作正常,如果不存在则用于创建目录。

标签: php rename


【解决方案1】:

问题在于文件名video-SunMar-15-18:03-2015-shared.mp4。 Windows 文件名中不允许使用冒号。

有关无效字符的更多信息,请参阅this list。

【讨论】:

  • 非常感谢您的帮助 :) :D ,对我帮助很大,我真的很感激。上帝祝福你。 :D
  • 没问题,很高兴它有帮助:)
猜你喜欢
  • 2017-05-27
  • 1970-01-01
  • 1970-01-01
  • 2020-06-07
  • 2020-04-08
  • 1970-01-01
  • 1970-01-01
  • 2021-01-07
  • 2019-04-29
相关资源
最近更新 更多