<?php
/**
* Copyright (C) 2021 Double Bastion LLC
*
* This file is part of Roundpin, which is licensed under the
* GNU Affero General Public License Version 3.0. The license terms
* are detailed in the "LICENSE.txt" file located in the root directory.
*/
session_start();
// // header('Set-Cookie: PHPSESSID= ' . session_id() . '; SameSite=strict; Secure=true; HttpOnly=true;');
if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
$userName = $_POST['username'];
$removedFileName = $_POST['removedfilename'];
$resmessage = "";
$totalFileSize = "";
$filePath = "../fax/temp_files/" . $userName . "/" . $removedFileName;
if (file_exists($filePath)) {
if (unlink($filePath)) { $resmessage = 'success'; } else { $resmessage = 'failure'; }
}
// Get the cumulative files size of the uploaded files
$targetdir = "../fax/temp_files/" . $userName;
$totalFlSize = 0;
foreach (new DirectoryIterator($targetdir) as $file) {
if ($file->isFile()) {
$totalFlSize += number_format(($file->getSize() / 1048576), 2);
}
}
$totalFileSize = $totalFlSize . " MB";
$respdata = ['result' => $resmessage, 'totalflsize' => $totalFileSize];
echo json_encode($respdata);
} else {
header("Location: ../login.php");
}
?>