Reputation: 69
In this example folder, I need to move all the contents of sub into the above directory using PHP in the move.php file.
▼ dir
- move.php
▼ sub
- a.txt
- b.txt
After move.php is run, the files should look like this:
▼ dir
- move.php
- a.txt
- b.txt
Thanks.
Upvotes: 1
Views: 92
Reputation: 5028
I will give you a hint.
php
file_get_contents('file_dir') to read the file into a stringphp
file_put_contents('file_dir') to create the filephp
unlink('file_dir') function to delete a file if necessaryphp
rmdir() function.If you do not need to access the files, you can just use php
copy($source, $dest) function to copy your files from one directory to another. Then you can delete them from old directory.
Upvotes: 1
Reputation: 739
Take a look at php scandir()
function to scan your sub-directory and move files from it to your current directory.
Upvotes: 1