note 56772 added to function.rename
| From: | tbrillon at gmail dot com | Date: | Wed, 14 Sep 2005 20:27:50 +0000 |
| Subject: | note 56772 added to function.rename | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-95188@lists.php.net to get a copy of this message | ||
I needed to move a file to another folder regardless if that file existed in the target already so I
wrote a small piece to append a unique number to each file.
$rem = $_GET['file'];
$ticket = uniqid(rand(), true);
rename("$rem", "www/home/storefile/$ticket$rem");
the output looks like this - 6881432893ad4925a1.70147481filename.txt
This also helps if you want different versions of the file stored.
----
Manual Page -- http://www.php.net/manual/en/function.rename.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+56772
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56772&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+56772&report=yes
Search -- http://master.php.net/manage/user-notes.php