3) Upload Files to more than one Location. |
To upload files to more than one location using Xload the procedure is easy. Just add the file parameter to the request and provide extra 'targeting' for this parameter on the server side and Xload will do the rest. For example, use the following code to upload a file to three different locations.
XloadManager xman = new XloadManager(request); xman.target("file1", "uploaded1"); xman.target("file1", "uploaded2"); xman.target("file1", 2048); xman.upload();
|
where:
request - HttpServletRequest object.
uploaded* - Directories to upload files to (relative to the web application directory).
file1 - File parameter inside html (or other) form.
The html on the client side would look like:
<form action="/my_servlet" enctype="multipart/form-data" method="post"> file1: <input type="file" name="file1"> </form>
|
The above code snippets would upload the file to two directories using their original ('remote') names (unless a file name collision occurs in which case the default rename policy comes into effect in this case), and also directly to memory (as opposed to disk) for potential use further on in the program. Notice that the third target() method call does not specify a specific location which indicates that the location for this target will be to memory (a memory load) but optionally specifies a maximum size of 2MB (specified in kilobytes).
IMPORTANT:- You can only have a single memory load for each file uploaded. If you specify multiple targets to memory for a file upload then only one target is used and the others are ignored. |
IMPORTANT:- The default maximum size for a file upload is 1GB. When you optionally specify a maximum size for a file upload then the default maximum size value of 1GB is ignored; if you specify more than one maximum size for a file upload then the lowest value is used for that file upload. |
© Gubutech(Xload) 2006 (v1.2)