From 89d571d245dc62716ebd31f6dffaf5c0898503b1 Mon Sep 17 00:00:00 2001 From: Pk11 Date: Thu, 13 Apr 2023 02:50:05 +0000 Subject: [PATCH] Handle file upload errors --- index.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/index.php b/index.php index 62fbdbf..9468aac 100644 --- a/index.php +++ b/index.php @@ -114,6 +114,12 @@ } // Validate and move the uploaded image file, if necessary + if($img['error'] != UPLOAD_ERR_OK && $img['error'] != UPLOAD_ERR_NO_FILE) { + if(!empty($img['tmp_name'])) + @unlink($img['tmp_name']); + return 'Invalid image, error ' . $img['error']; + } + if(!empty($img['tmp_name'])) { if((($img['type'] == 'image/gif') || ($img['type'] == 'image/jpeg') || ($img['type'] == 'image/pjpeg') || ($img['type'] == 'image/png') || ($img['type'] == 'image/bmp'))