> 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...
Try using $HTTP_POST_FILES['uploadedFile']['name'] instead. I wasted a bunch
of time yesterday with an upload script that did not recognize files when
using "$_FILES", but worked fine with "$HTTP_POST_FILES" -- PHP 4.3.4 on
Linux.
--
Lowell Allen
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php