What is the potential issue with the file upload function in the provided PHP code?

The potential issue with the file upload function in the provided PHP code is that it does not check for file type validation. This can lead to security vulnerabilities such as allowing users to upload malicious files. To solve this issue, you should add a file type validation check before allowing the file to be uploaded.

// Check if file type is allowed before uploading
$allowedFileTypes = array('jpg', 'jpeg', 'png', 'gif');
$extension = pathinfo($_FILES['file']['name'], PATHINFO_EXTENSION);

if (!in_array($extension, $allowedFileTypes)) {
    echo "Invalid file type. Only JPG, JPEG, PNG, and GIF files are allowed.";
} else {
    // Upload file logic here
}