if (in_array($fileMimeType, $allowedMimeTypes)) { if ($fileError === UPLOAD_ERR_OK) { if (move_uploaded_file($fileTmpName, $uploadDir . $fileName)) { chmod($uploadDir . $fileName, 0440); echo"File uploaded successfully. <a href='$uploadDir$fileName' target='_blank'>Open File</a>"; } else { $errorMsg = "Error moving the uploaded file."; } } else { $errorMsg = "File upload failed with error code: $fileError"; } } else { $errorMsg = "Don't try to fool me, this is not a png file"; } } else { $errorMsg = "File size should be less than 200KB, and only png, jpeg, and jpg are allowed"; } }