note 90025 modified in function.rename by danbrown

From: Date: Thu, 02 Apr 2009 13:32:28 +0000
Subject: note 90025 modified in function.rename by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-152756@lists.php.net to get a copy of this message
Note that this WILL NOT WORK if trying to rename a directory to a network share. e.g. rename('/home/user/me/dir1', '/mnt/shares/nfsmount/dir2') will create a file called 'dir2' on the share and not a directory. This caught me out and my (quickest) solution was to use an exec and mv command: <?php $cmd = 'mv "/home/user/me/dir1" "/mnt/shares/nfsmount/dir2"'; exec($cmd, $output, $return_val); if ($return_val == 0) { echo "success"; } else { echo "failed"; } ?> --was-- Note that this WILL NOT WORK if trying to rename a directory to a network share. e.g. rename('/home/user/me/dir1', '/mnt/shares/nfsmount/dir2') will create a file called 'dir2' on the share and not a directory. This caught me out and my (quickest) solution was to use an exec and mv command: <?php $cmd = 'mv "/home/user/me/dir1" "/mnt/shares/nfsmount/dir2"'; exec($cmd, $output, $return_val); if ($return_val == 0) { echo "success"; } else { echo "failed"; } http://php.net/manual/en/function.rename.php

« previous php.notes (#152756) next »