note 37082 added to function.copy
| From: | m at densityonline dot com | Date: | Sun, 02 Nov 2003 16:33:24 +0000 |
| Subject: | note 37082 added to function.copy | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59654@lists.php.net to get a copy of this message | ||
Some servers may produce errors when you try to copy into a folder with an existing file in there
already. Instead of overwriting the file, you may get "PERMISSION DENIED" error messages.
In order to solve the problem, I ran a file_exists() function to check if there are any existing,
matching files inside the destination folder. If so, then we delete the file first (using the
unlink() function) before we perform the copy() operations into the destination folder.
Eg:
$source_file = "path/to/source/file";
$destination_file = "path/to/destination/file";
if (file_exists($destination_file))
{
unlink ($destination_file);
}
copy ($source_file, $destination_file);
-mike tee-
----
Manual Page -- http://www.php.net/manual/en/function.copy.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+37082
Delete -- http://master.php.net/manage/user-notes.php?action=delete+37082&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+37082&report=yes
Search -- http://master.php.net/manage/user-notes.php