In the form, enctype = "multipart/form-data" indicates the MIME encoding of the form. By default, the encoding format is application/x-www-form-urlencoded and cannot be used for file upload. Only multipart/form-data can be used to completely transmit file data, perform the following operations.
Enctype = "multipart/form-data" is used to upload binary data;
The input values in form are passed in binary format.
The input value in form is passed in binary format, so the request will not get the value. That is to say, after this code is added, the request will fail to be passed. When you add the form value to the database, the following code is used:
- SmartUpload upload =NewSmartupload ();
- Try{
- Upload. initialize (config, request, response );
- // File type that can be uploaded
- Upload. setallowedfileslist ("Doc, xls ,");
- // Type of the object to be uploaded
- Upload. setdeniedfileslist ("EXE, bat, jsp ");
- // The maximum size of a file that can be uploaded
- Upload. setmaxfilesize (1024*1024*20 );
- // Maximum size of objects allowed to be uploaded
- // Upload. settotalmaxfilesize (1024*1024*10 );
- // Upload data
- Upload. upload ();
- }
- Catch(SmartUploadException e ){
- E. printStackTrace ();
- Return;
- }
- Request req = upload. getRequest ();
- String spid = (String) req. getParameter ("teacherId ");
- //.....
- // To do something
SmartUpload upload = new SmartUpload (); try {upload. initialize (config, request, response); // the file type that can be uploaded upload. setAllowedFilesList ("doc, xls,"); // upload type of the file that is rejected. setDeniedFilesList ("exe, bat, jsp"); // the maximum size of a file that can be uploaded. setMaxFileSize (1024*1024*20); // maximum size of the file to be uploaded // upload. setTotalMaxFileSize (1024*1024*10); // upload data upload. upload ();} catch (SmartUploadException e) {e. printStackTrace (); return;} Request req = upload. getRequest (); String spid = (String) req. getParameter ("teacherId ");//..... // To do something