Rename generates level 2 warning but works

From: Roger Spears (roger_at_bgnet.bgsu.edu)
Date: 12/31/03


Date: Wed, 31 Dec 2003 10:29:48 -0500
To: PHP General <php-general@lists.php.net>

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



Relevant Pages

  • Re: I cannot rename any file or folder.
    ... known file types" box is UNchecked, you have to type the correct file ... or you'll get the warning you describe. ... > that particular folder / file it will not work but you have been warned. ... >> When I try to rename a file or folder I get the warning that if I do ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: I cannot rename any file or folder.
    ... "tom" wrote: ... or you'll get the warning you describe. ... >> that particular folder / file it will not work but you have been warned. ... >>> When I try to rename a file or folder I get the warning that if I do ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: I cannot rename any file or folder.
    ... This is just a warning. ... In most instances it is OK to proceed with renaming ... particular folder / file it will not work but you have been warned. ... > to rename it, it will become unusable. ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Save As dialog file saving/renaming bug?
    ... If you try this with office file you aren't allowed to rename them. ... In Windows XP I can no longer do that, because there's a bug in that dialog. ... Navigate to the folder you saved "renamebug.txt" in in the dialog's file list box if necessary, right-click "renamebug.txt", choose rename and rename the file to "renamefeature.txt". ... "File name" text box remains unchanged and upon hitting the Save button the file is saved as "renamebug.txt" without any warning. ...
    (microsoft.public.windowsxp.general)
  • Re: [fuse-devel] [PATCH 01/25] VFS: move attr_kill logic from notify_change into helper function
    ... be no error or warning on an unconverted fs. ... security holes. ... If we would rename the setattr method to setattr_new as well as ...
    (Linux-Kernel)