Pictures and other files upload is different from simple numbers, files in the computer in the form of binary, file upload to use the Smartupload components. Let's learn how to use the Smartupload component to upload files.
Smartupload Introduction
Smartupload is a www.jspsmart.com Web site developed a set of upload components package, can facilitate the implementation of file upload and download functions, smartupload components used is very simple, you can upload file types of restrictions, can easily get the name of the uploaded file, suffix, size and so on.
The smartupload itself is a system-supplied jar package (and the principle of importing the package as a database operation), where the user directly places the packet under Classpath or directly into the Tomcat_homelib directory.
Note: There are a lot of files uploaded, Smartupload is just one of them, but the www.jspsmart.com website that provides this component has been shut down, but until today Smartupload has been widely used until now because it's easy to use.
Example to explain the application of Smartupload component uploading files
This example will upload a picture on my desktop named Dahai.jpg to the folder upload.
Use this component to upload, in the upload when there is one thing to note is that you have to choose a good file to upload is which, this choice is definitely by the HTML form to complete.
Because the file is to be uploaded, the form must be encapsulated, because it is no longer normal text data, and the form's encapsulation is done by enctype.
smart_01.html
Here's what to note:
1. Due to the fact that the uploaded files are generally relatively large, method uses post instead of get because get is limited by the length of the address bar.
2.enctype= "Multipart/form-data" said will be submitted in the form of binary, because the pictures and other documents are not pure numbers, but binary form of the file.
Now that the form has been completed, the upload can be done via smartupload. Before uploading, do the following steps:
1. Create a upload folder to hold the uploaded items (picture dahai.jpg). This folder is created in MyEclipse as shown in the following illustration: