From 3fbd6645d5df91327e3445b41231f4bfd564674b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zden=C4=9Bk=20Borovec?= Date: Sun, 23 Jun 2024 05:41:18 +0200 Subject: [PATCH] fileupload preserve extension --- docs/www/fileupload.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/www/fileupload.php b/docs/www/fileupload.php index 0c7aaf6..ad2f2f5 100644 --- a/docs/www/fileupload.php +++ b/docs/www/fileupload.php @@ -20,7 +20,8 @@ if(isset($_POST["submit"])) { $firstDir = bin2hex(random_bytes(16)); $secondDir = bin2hex(random_bytes(16)); $filename = bin2hex(random_bytes(16)); - $combinedPath = $firstDir."/".$secondDir."/".$filename; + $extension = pathinfo($_FILES['userfile']['name'], PATHINFO_EXTENSION);; + $combinedPath = $firstDir."/".$secondDir."/".$filename.".".$extension; mkdir($uploadDir.$firstDir, 0774); mkdir($uploadDir.$firstDir."/".$secondDir, 0774);