Enctype : Specifies the type of encoding the browser uses when posting data back to the server. Used for uploading pictures in forms. There are three encoding types: application/x-www-form-urlencoded: Encode all characters before sending (default). This is the standard encoding format. multipart/form-data: Do not encode characters. This value must be used when using a form that contains a file upload control. text/plain: The form data is encoded as plain text, without any controls or formatting characters. example: Copy code The code is as follows:<form action="${pageContext.request.contextPath}/imageUpload_saveOrUpdate.action" method="post" enctype="multipart/form-data"> <div> <label>Please select the upload image address:</label> <input type="file" name="image"/> </div> </div> <div> <input type="submit" value="Upload"/> </div> </form> The meaning of enctype="multipart/form-data" in the form is to set the MIME encoding of the form. By default, the encoding format is application/x-www-form-urlencoded, which cannot be used for file uploads; only when multipart/form-data is used can the file data be fully transmitted. enctype="multipart/form-data" is used to upload binary data. If you want to obtain the value of the corresponding form field through the Request object on the server side, you should set the enctype attribute to application/x-www-form-urlencoded (that is, the default value, which can be omitted). Why do you need to set enctype="multipart/form-data" when uploading files? Because: after setting enctype to multipart/form-data, if the characters are not encoded, the data is transmitted to the server in binary form. At this time, if you use request, you cannot directly get the value of the corresponding form. Instead, you should use the stream object to decode the binary data transmitted to the server and read the data. If you want to upload a file, you must set the encotype to multipart/form-data. |
<<: Detailed Example of CSS3 box-shadow Property
>>: Vue implements internationalization of web page language switching
Public free STUN servers When the SIP terminal us...
Today we will make a simple case, using js and jq...
1.MySQL version [root@clq system]# mysql -v Welco...
In rows, dark border colors can be defined indivi...
You can go to the Ubuntu official website to down...
Table of contents Preface: 1. Install Docker 2. I...
Recently, the server has been frequently cracked ...
When learning Vue, when I always use webpack inst...
Table of contents Congruent and Incongruent congr...
Table of contents Jenkins installation Install Ch...
Although W3C has established some standards for HT...
Table of contents 1. Introduction to MHA 1. What ...
Mapping the mouse position or implementing drag e...
Abstract: Whether at work or in an interview, opt...
01. Command Overview basename - strip directories...