What is the importance of using enctype="multipart/form-data" in an HTML form for file uploads in PHP?

When uploading files through an HTML form in PHP, it is important to use enctype="multipart/form-data" in the form tag. This attribute specifies how the form data should be encoded when submitting it to the server, allowing files to be uploaded successfully. Without this attribute, the file data will not be correctly transmitted to the server, resulting in failed file uploads.

<form action="upload.php" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="Upload">
</form>