enctype 属性规定在发送到服务器之前应该如何对表单数据进行编码。
如下:
<form action="upload.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="1000000"> 选择文件: <input type="file" name="myfile"> <input type="submit" value="上传文件"> </form>
表单中 enctype="multipart/form-data" 的意思,是设置表单的 MIME 编码。
默认情况,这个编码格式是 application/x-www-form-urlencoded,不能用于文件上传;
只有使用了multipart/form-data,才能完整的传递文件数据,进行下面的操作。
enctype="multipart/form-data" 是上传二进制数据;