Form: enctype = "multipart/form-data"

Source: Internet
Author: User

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:

 

  1. SmartUpload upload =NewSmartupload ();
  2. Try{
  3. Upload. initialize (config, request, response );
  4. // File type that can be uploaded
  5. Upload. setallowedfileslist ("Doc, xls ,");
  6. // Type of the object to be uploaded
  7. Upload. setdeniedfileslist ("EXE, bat, jsp ");
  8. // The maximum size of a file that can be uploaded
  9. Upload. setmaxfilesize (1024*1024*20 );
  10. // Maximum size of objects allowed to be uploaded
  11. // Upload. settotalmaxfilesize (1024*1024*10 );
  12. // Upload data
  13. Upload. upload ();
  14. }
  15. Catch(SmartUploadException e ){
  16. E. printStackTrace ();
  17. Return;
  18. }
  19. Request req = upload. getRequest ();
  20. String spid = (String) req. getParameter ("teacherId ");
  21. //.....
  22. // 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.