Reputation: 5316
How i can copy one file from one directory to another directory using php
Upvotes: 1
Views: 1870
Reputation: 3523
If you are moving a file just uploaded, use http://php.net/manual/en/function.move-uploaded-file.php instead of rename(). It gives you some added security.
Upvotes: 0
Reputation: 317217
You can use
copy
— Copies fileExample from Manual:
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...\n";
}
Upvotes: 6
Reputation: 21947
rename('path/to/file/file.ext', 'path2/to2/file2/file.ext');
Upvotes: 3