hsn0331
hsn0331

Reputation: 394

php: Warning: rename The filename, directory name, or volume label syntax is incorrect. (code: 123)

Since I am trying to copy my file I am getting this error, I am using windows 8.1

Warning: rename(../user/will/video/javascript-toggle-buttons-MonMar09122015-7491.mp4,../user/will/video/video-SunMar-15-18:03-2015-shared.mp4): The filename, directory name, or volume label syntax is incorrect. (code: 123) in E:\xampp\htdocs\social_media\root\php_parsers\status_system.php on line 353

this is I am trying to do,

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);
}

What's wrong with this? I am tired of watching this error :( and really frustrated.

Upvotes: 2

Views: 4754

Answers (1)

rjdown
rjdown

Reputation: 9227

The problem is in the file name video-SunMar-15-18:03-2015-shared.mp4. Colons are not allowed in Windows filenames.

Please see this list for more information about invalid characters.

Upvotes: 7

Related Questions