The role of Enctype=multipart/form-data in form

ENCTYPE=”multipart/form-data” is used for uploading images in forms.

<form name="userInfo" method="post" action="first_submit.jsp"    ENCTYPE="multipart/form-data"> 

Set enctype="multipart/form-data" in the form tag to ensure proper encoding of anonymously uploaded files.
as follows:

<tr> 
      <td height="30" align="right">上传企业营业执照图片:</td> 
      <td><INPUT TYPE="FILE" NAME="uploadfile" SIZE="34"    onChange="checkimage()"></td> 
</tr> 

You have to add ENCTYPE=”multipart/form-data”.

The meaning of enctype=”multipart/form-data” in the form is to set the MIME encoding of the form. By default, this encoding format is application/x-www-form-urlencoded, which cannot be used for file uploading; only when multipart/form-data is used, the file data can be completely transmitted, and the following operations can be performed. enctype=”multipart/form -data" is to upload binary data; the input value in the form is passed in binary format.

The value of the input in the form is passed in binary format, so the request will not get the value. That is to say, if this code is added, the request will be unsuccessfully delivered. When the form value is added to the database, the following is used:

SmartUpload su = new SmartUpload();//新建一个SmartUpload对象 

su.getRequest().getParameterValues();取数组值 

su.getRequest().getParameter( );取单个参数单个值 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326052140&siteId=291194637