Using Jspsmartupload to implement file uploads

Source: Internet
Author: User

1.1. Use Jspsmartupload to implement file upload 1.1.1. Create a new Web project 1.1.2. Upload page index.jsp

<%@ page language= "java" contenttype= "text/html; Charset=utf-8 "         pageencoding=" Utf-8 "%><! DOCTYPE html>

1.1.3. File Upload processing Filesmartupload.java

Package com.jsp.file.upload.servlet; Import Java.io.ioexception;import java.sql.SQLException; Import Javax.servlet.servletexception;import Javax.servlet.annotation.webservlet;import Javax.servlet.http.httpservlet;import Javax.servlet.http.httpservletrequest;import Javax.servlet.http.HttpServletResponse; Import Com.jspsmart.upload.smartupload;import com.jspsmart.upload.SmartUploadException; @WebServlet ("/filesmartupload") public class Filesmartupload extends HttpServlet {private static final long Seri          Alversionuid = 1L; public void DoPost (HttpServletRequest request, httpservletresponse response) throws Servletexce Ption, ioexception{//Create File Upload object Smartupload smartupload = new Smartu                   Pload ();                   Initialize File Upload Object Smartupload.initialize (This.getservletconfig (), request, response); Sets the maximum number of bytes for a single file Smartupload.setmaxfilesize (1000*100);                   Sets the maximum number of bytes for the total file smartupload.settotalmaxfilesize (1000*1000*100);                   Set the allowable file extension smartupload.setallowedfileslist ("Jpg,doc,rar,txt,java");                            try {//Set disallowed file extension smartupload.setdeniedfileslist ("exe,php");                            Upload file Smartupload.upload ();                                              Save the file, specify the path to Smartupload.save ("d://");                   } catch (SQLException e) {e.printstacktrace ();                   } catch (Smartuploadexception e) {e.printstacktrace (); }         } }


Using Jspsmartupload to implement file uploads

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.