Rename generates level 2 warning but works
| From: | Roger Spears | Date: | Wed, 31 Dec 2003 15:29:48 +0000 |
| Subject: | Rename generates level 2 warning but works | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-173545@lists.php.net to get a copy of this message | ||
Hello,
I have this magical script which uses rename. A visitor to the site uploads a file and I want to rename it to a timestamp. Oddly enough, the rename() function actually works, it renames the file AND then generates a level 2 warning:
Error code: 2
Error message: rename() failed (No such file or directory)
Why does it work AND create a warning?
Here's the snippet of code:
$rename = time();
$old_name = $_FILES['uploadedFile']['name'];
$read_extension = explode(".", $old_name);
$ext = $read_extension[1];
$new_name = $rename.".".$ext;
rename($old_name, $new_name);
I know I can suppress the the warning with @, but I'm more interested in WHY this warning gets generated. I'm using PHP 4.2.2 on a Linux box. Any hints or suggestions are greatly appreciated...
Thanks,
Roger