"Wrong file type gameFile"]); exit(); } } /** * @param string $thumbnailFileName * @param string $thumbnailFileTmp * @return string */ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp): string { $fileExtThumb = explode('.', $thumbnailFileName); $fileActualExtThumb = strtolower(end($fileExtThumb)); $headerType = mime_content_type($thumbnailFileTmp); $headerTypeMatch = array('image/png', 'image/jpeg','image/gif', 'image/svg+xml',); if(in_array($headerType,$headerTypeMatch)){ $thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb; if(empty($thumbnailFileName)){ http_response_code(400); exit(); } rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName); return $thumbnailFileNewName; }else{ http_response_code(400); echo json_encode(["message" => "Wrong file type thumbnailFile"]); exit(); } }