What are the benefits of using enctype="multipart/form-data" in HTML forms for file uploads?

When uploading files through HTML forms, using enctype="multipart/form-data" is necessary to ensure that the file data is properly encoded and sent to the server. Without this attribute, the file data will not be transmitted correctly, leading to potential errors or incomplete uploads.

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