From b5777e4f5fa49e1476a3265ab8ddec5c457ce918 Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Thu, 12 Sep 2024 00:38:21 +0200 Subject: [PATCH] Delete origine file --- app.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/app.php b/app.php index 9fa74f7..09f555f 100644 --- a/app.php +++ b/app.php @@ -429,22 +429,17 @@ function($f3) { if ($returnCode === false) { echo "PDF compression failed."; - unlink($outputFileName); - return; - } - - if (filesize($filePath) <= filesize($outputFileName)) { + } elseif (filesize($filePath) <= filesize($outputFileName)) { $error = "pdfalreadyoptimized"; - unlink($outputFileName); header('location: /compress?err=' . $error); - return; + } else { + header('Content-Type: application/pdf'); + header("Content-Disposition: attachment; filename=$outputFileName"); + readfile($outputFileName); } - header('Content-Type: application/pdf'); - header("Content-Disposition: attachment; filename=$outputFileName"); - readfile($outputFileName); - unlink($outputFileName); + unlink($filePath); } );