A solution based on Java Web file upload progress display

xiaoxiao2021-03-06  115

In web application development, you often encounter files to download and download modules. Whether IE or common FlashGets, download software, you can make users clearly understand the progress of download, especially When carrying out major file transfer, it provides users with very comfortable feeling ... I can imagine that a few hundred m or the file transfer process of a few M or the G G does not have progress. What is unbearable thing. ? However, in most of the most server upload components, it is not possible to provide a display function of the file upload schedule or the corresponding development interface. When a large file upload operation or a low-speed network upload, long-term ignorant states often allow the user to measures. • This article (and corresponding components) provides a solution for Java Web-based HTTP file upload schedules, which can be applied to JSP, servlet web application development, which extends by Apache's Commons-FileUpload-1.0 component However, there is no change in any original component code, and the progress display section appears in an extension component, you can use or not use this display component at any time without having to make a large-scale change for the original upload application. AHXU-Commons-FileUploadex-1.0 extends the following features on the basis of Apache's Commons-fileupload-1.0: 1. Increase the file type detection function, you can set the type of upload file, not being allowed to be uploaded, will not be uploaded; 2. Increase the filtering function on the non-file domain form, you can select or do not select a form content that receives the non-file domain; 3. Add the file upload schedule function, dynamically report the file name, size, speed, and speed, Total time, remaining time, etc., and provide a solution based on this progress reporting function;

Installation (TOMCAT-5.0.27 as an example): 1. Download Apache's Commons-FileUpload-1.0 component download address http://apache.linuxForum.Net/dist/jakarta/commons/fileupload/binaries/commons-fileUpload-1.0 .zip2. Download AHXU's AHXU-COMMONS-FILEUPLOADEX-1.0 component download address http://briefcase.tom.com/download.php?fileId=507578, decompress .jar. 3. Put this two .jar files into a web-inf / lib directory for a configured web application, for example: test / web-inf / lib test: 1. Download application test code UPLOAD-JSP.RAR, Download address http://briefcase.tom.com/download.php?fileId=507579, unzip the root directory of this web application, for example: test / 2. Run Upload.jsp, require IE5.0 or more, for example: http://127.0.0.1/test/upload.jsp3. Select one or two big points of the file, preferably a few hundred m, then upload, one progress dialog box will pop up during the upload process, as shown

Installation (take Tomcat-5.0.27 as an example):

1. Download Apache's Commons-FileUpload-1.0 component

download link

http://apache.linuxForum.Net/dist/jakarta/commons/fileupload/binaries/commons-fileupload-1.0.zip

2. Download AHXU's AHXU-COMMONS-FILEUPLOADEX-1.0 component

download link

Http://briefcase.tom.com/download.php?fileId=507578, unzipped .jar. 3. Put this two .jar files in a web-inf / lib directory for a configured web application, for example: test / web-inf / lib

test:

1. Download the application test code UPLOAD-JSP.RAR, download address

http://briefcase.tom.com/download.php?fileid=507579

, Unzip the root directory placed in this web application, for example: TEST /

2. Run Upload.jsp, require IE5.0 or more, for example:

http://127.0.0.1/test/upload.jsp

3. Select one or two big points of files, preferably a few hundred m, then upload, one progress dialog box will pop up during the upload, as shown

Figure 1 File Upload Progress Display Dialog

4. After the file is uploaded, the upload result is displayed, and the progress dialog is automatically turned off. Note: The above process passes the Win2000 SP4 Tomcat 5.0.27 IE6.0 test, whether other environments can run normally, I hope everyone will feed back to me after testing, thank you!

Useful UPLOAD-JSP.rar:

4 files included in UPLOAD-JSP.rar: Upload.jsp, Receive.jsp, ProgressBar.jsp, ProgressDetail.jsp

1. UPLOAD.JSP - File upload form; this page contains the FORM form uploaded by files, of course, you can also have any files you like in your app to upload the Form form page. This page calls the JavaScript function uploadbegin () pop-up schedule dialog box (Show ProgressBar.jsp) when Submit; you can customize it yourself, such as you don't use the dialog, use iFrame. But the Form's onSubmit should call UploadBegin (), such as: