} #Download New Transactions if (isset($_GET["download_transaction"])) { $TransactionsArr = db_function::transaction_select_all_order_by_date(); if (!empty($TransactionsArr)) { for ($i = 0; $i < sizeof($TransactionsArr); $i++) { $TransactionsArr[$i]['Attachments'] = implode(";", attachments::get_attachments_filename_array((int) $TransactionsArr[$i]['ID'])); } echo json_encode($TransactionsArr, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_FORCE_OBJECT); } } #Download Attachments by name if (isset($_GET["download_attachment"])) { $AttachmentFileName = $_GET["download_attachment"]; if (!empty($AttachmentFileName)) { $FullPath = costant::attachments_folder() . "/" . $AttachmentFileName; header("Content-Type:"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename= " . $AttachmentFileName); header("Content-Transfer-Encoding: binary"); readfile($FullPath); } } #Delete Attachments if (isset($_GET["delete_attachment"])) { $AttachmentFileName = $_GET["delete_attachment"]; if (!empty($AttachmentFileName)) { attachments::delete_attachment_by_name($AttachmentFileName); } }
public static function delete_attachment_by_name($FileName) { $FullPath = costant::attachments_folder() . "/" . $FileName; if (!empty($FileName) && file_exists($FullPath)) { unlink($FullPath); } }