Hi, Today I am going to talk about how to move files with php
There are two ways to do it.
1. Copy and Delete
First you have to copy that file you want to move to where you want and then delete the old copy.
$file = 'folder1/example.txt'; $newfile = 'folder2/example.txt'; copy($file, $newfile); unlink(file);
2. Using Rename Function
This one is easier than the first one.You have to give the path of the file that you want to move in the first parameter of the rename() function.
Then give the new path for the file in the second parameter (give the path with the file name).
$file = 'folder1/example.txt'; $newfile = 'folder2/example.txt'; rename($file,$newfile);
. . .
This was originally posted on one of my old blog – CodingWar.com