What I am trying to do is creating a zip file
public function createFilesBackup()
{
$dir = home_path();
$sitePath = realpath($dir);
$zip = new ZipArchive();
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($sitePath),
RecursiveIteratorIterator::LEAVES_ONLY
);
$zipName = 'backup_'.date('Y-m-d').'.zip';
$zipfileName = $sitePath."/wp-content/uploads/".$zipName;
$zip->open($zipfileName, ZipArchive::CREATE | ZipArchive::OVERWRITE);
foreach ($files as $name => $file)
{
if (!$file->isDir())
{
$filePath = $file->getRealPath();
$relativePath = substr($filePath, strlen($sitePath) + 1);
$zip->addFile($filePath, $relativePath);
}
}
$zip->close();
return get_site_url()."/".$zipName;
}
And this is what I am getting Can anyone help me out I would be a great
Fatal error: Uncaught RuntimeException: SplFileInfo::isDir(): open_basedir restriction in effect. File(/home/abdulbasit/web/checkout-demo.wholisticleather.com/public_html/..) is not within the allowed path(s): (/home/abdulbasit/web/checkout-demo.wholisticleather.com/public_html:/home/abdulbasit/tmp) in /home/abdulbasit/web/checkout-demo.wholisticleather.com/public_html/wp-content/plugins/MerchantypayWPBackup/MerchantypayWPBackup.php:66 Stack trace: #0 /home/abdulbasit/web/checkout-demo.wholisticleather.com/public_html/wp-content/plugins/MerchantypayWPBackup/MerchantypayWPBackup.php(66): SplFileInfo->isDir() #1 /home/abdulbasit/web/checkout-demo.wholisticleather.com/public_html/wp-content/plugins/MerchantypayWPBackup/cron.php(23): MerchantypayWPBackup->createFilesBackup('/home/abdulbasi...', '/home/abdulbasi...') #2 {main} thrown in