How should file upload data be handled in PHP compared to regular post variables?

When handling file upload data in PHP, you need to use the $_FILES superglobal array instead of the $_POST array. This is because file uploads are sent as multipart form data, not as regular post variables. You should also ensure that the form has the attribute enctype="multipart/form-data" set in order to handle file uploads correctly.

if(isset($_FILES['file'])){
    $file_name = $_FILES['file']['name'];
    $file_tmp = $_FILES['file']['tmp_name'];
    $file_size = $_FILES['file']['size'];
    $file_type = $_FILES['file']['type'];

    move_uploaded_file($file_tmp, "uploads/" . $file_name);
    echo "File uploaded successfully!";
}