I am trying to create a json file and each time I enter the page using this.
if(!isset($_SESSION['backup_active']))
{
$backup=fopen("backup/".time().".json", "w");
fwrite($backup, json_encode($list)); fclose($backup);
$_SESSION['backup_active']=true;
}
What this does is that when I enter the page it creates the backup but when I delete the backup file and try again it wont create a new one. After I create my backup file I want to call it and put it in another .json file like this.
session_start();
if(isset($_SESSION['backup_active']))
{
$fBackup= "backup";
$lastFile= end($fBackup);
$listFile = file_get_contents($lastFile);
file_put_contents('list.json', $listFile);
session_destroy();
}
But this doesn't seem to work. I use the end() method to take the last made backup file and then put it in the list.json file.
Can anyone help me fix this problem?