How to copy few files from one folder to another folder in php and delete them in source folder -
How to copy files from one folder to another folder in PHP and delete them in the source folder?
I have two folders $ incoming_file_path = / home / xmlcontainer
and $ processing_file_path = home / process_file
. I am piping through all the files in $ incoming_file_path = home / xmlcontainer
and instead of copying it to $ processing_file_path = home / process_file
After executing the code I am not able to copy the content of files, but the name of the files is not even able to delete files, which I have
code
foreach (globe $ incoming_file_path. '/ *') $ Key = & gt; $ value) {copy ($ incoming_file_path. $ Value, $ Processing_file_path). $ Value); Unlink ($ incoming_file_path $ value.); }
First of all, if you intend to move files, then its Use the.
Your loop should look like this:
foreach ($ coming_file_path ./ * ') as $ value) {Rename ($ value, $ Processing_file_path. '/'. Basic name ($ value))}
Inability to read and / or delete file contents is often a simple permissions problem. Check whether the owner of your PHP process can read and write both $ incoming_file_path
and $ processing_file_path
. You want to execute chmod-R u + rwx
(or chmod -R o + rwx
) on both $ incoming_file_path
and $ Processing_file_path
.
Comments
Post a Comment