What are the potential pitfalls of using the $HTTP_POST_FILES variable in PHP for file uploads and what is the recommended alternative?

Using the $HTTP_POST_FILES variable in PHP for file uploads is not recommended as it is deprecated and insecure. The recommended alternative is to use the $_FILES superglobal array to handle file uploads securely and efficiently.

// Example of handling file upload using $_FILES superglobal
if(isset($_FILES['file'])){
    $file_name = $_FILES['file']['name'];
    $file_tmp = $_FILES['file']['tmp_name'];
    
    move_uploaded_file($file_tmp, "uploads/" . $file_name);
    echo "File uploaded successfully!";
}