I have a folder that I am fetching xml file contents from and inserting them into a database. The challenge that I have is to move files from original destination to another destination which in this case works as a backup storage.
Below is my code I am using to fetch file contents and inserting them into database.
public function store(Request $request)
{
$directory = storage_path('app/xmlentries/uploads'); //Folder I am getting file contents from
$files = File::allFiles($directory);
foreach ($files as $file) {
$contents = $file->getContents();
foreach ((array) $contents as $content) {
$simpleXml = simplexml_load_string($content);
$data = [
'experience' => $simpleXml->ExportData->Requisition->EssentialFunction,
'job_requirements' => $simpleXml->ExportData->Requisition->EssentialFunction,
];
Vacancy::insert($data);
}
}
$processed = storage_path('app/xmlentries/processed'); //Folder that I must move files to
File::move($processed);
}
Please note that the inserting of file contents to database works fine.
How would i move my files from $directory to $processed ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire