NYCPHP Meetup

NYPHP.org

[nycphp-talk] Moving a file

Craig Thomas craig at juxtadigital.com
Sat Sep 23 14:24:38 EDT 2006


David Krings wrote:
> Hi,
> 
> after looking around for a while it appears as that there is no single 
> command to move a file from A to B. I know that I can first copy the file 
> and then delete the source. In order to do so I'd need to check if the copy 
> was successful and then check if the delete was successful. Is that so or 
> am I just too dense to read the docs right?
> 
> Answering my own question but assuming that this may be interesting for 
> some, I am not to dense. OK, that wasn't too interesting, I admit. What is 
> interesting is that there is indeed no move function per sé, but I saw at 
> http://webxadmin.free.fr/article/php-move-file-211.php that you can abuse 
> the rename function to move a file...and potentially rename it at the same 
> time.

if you are using *nix you can mv files:

exec("mv /path/to/oldfile /path/to/newFile");




More information about the talk mailing list