Uploading of files
As mentioned earlier, the file upload and download, all through the operation of IO stream to achieve, so the following directly write a simple example of file upload function
First step: Import the jar package
Yes, and the download is a package
Step two: Setting up the foreground page
Requires that the form must be a multipart form, and that the submission must be post, with at least one file upload tag, which must have the name attribute, or it will be meaningless
//get File Upload Download objectSmartupload su =Newsmartupload (); //InitializeSu.initialize ( This. Getservletconfig (), request,response); Try { //get the uploaded contentsu.upload (); //save in Server root directorySu.save ("/"); } Catch(smartuploadexception e) {//TODO auto-generated Catch blockE.printstacktrace (); }
This jar package can also set the file upload format, size, etc., you can also set the name of the file save, etc.
File upload-use packaged rack packages