From 19025fa07f18b2830705ab954e5585b6c12ad57c Mon Sep 17 00:00:00 2001 From: Vincent LAURENT Date: Thu, 11 Nov 2021 10:06:42 +0100 Subject: [PATCH] =?UTF-8?q?Le=20nom=20de=20fichier=20du=20pdf=20est=20stoc?= =?UTF-8?q?k=C3=A9=20en=20js=20avant=20l'upload=20ce=20qui=20=C3=A9vite=20?= =?UTF-8?q?de=20passer=20en=20session=20apr=C3=A8s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.php | 13 ++----------- templates/index.html.php | 7 +++++++ templates/pdf.html.php | 7 ------- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/app.php b/app.php index a1c7a9b..56597c4 100644 --- a/app.php +++ b/app.php @@ -27,7 +27,6 @@ $f3->route('POST /upload', $f3->error(403); } - $fileName = null; $files = Web::instance()->receive(function($file,$formFieldName){ if(Web::instance()->mime($file['tmp_name'], true) != 'application/pdf') { @@ -35,8 +34,7 @@ $f3->route('POST /upload', } return true; - }, true, function($fileBaseName, $formFieldName) use (&$fileName, $key) { - $fileName = $fileBaseName; + }, true, function($fileBaseName, $formFieldName) use ($key) { return $key.".pdf"; }); @@ -53,20 +51,13 @@ $f3->route('POST /upload', $f3->error(403); } - if($fileName) { - $f3->set('SESSION.fileName', $fileName); - } - return $f3->reroute('/'.$key); } ); $f3->route('GET /@key', function($f3) { $f3->set('key', $f3->get('PARAMS.key')); - if($f3->get('SESSION.fileName')) { - $f3->set('fileName', $f3->get('SESSION.fileName')); - $f3->clear('SESSION.fileName'); - } + echo View::instance()->render('pdf.html.php'); } ); diff --git a/templates/index.html.php b/templates/index.html.php index 45a7bf2..a2615e1 100644 --- a/templates/index.html.php +++ b/templates/index.html.php @@ -33,7 +33,14 @@