file(s) must be selected by direct action of the user. The basic
structure is:
On the client side, a GWT FormPanel containing a FileUpload widget
(and optionally other information, e.g. one or more Hidden fields
containing information that will be meaningful to your servlet).
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/FileUpload.html
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/FormPanel.html
http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/client/ui/Hidden.html
Let's assume that your servlet URL is /fileUploadServlet. Your
FormPanel needs to do something like this:
private static final String SERVLET = "/fileUploadServlet";
setAction(SERVLET);
setEncoding(ENCODING_MULTIPART);
setMethod(METHOD_POST);
One the server side, you want to install the Apache FileUpload package
from here:
http://commons.apache.org/fileupload/
Using those helper functions in that package, the doPost method in
your FileUploadServlet class becomes straightforward. Just choose
from one of these examples:
http://commons.apache.org/fileupload/using.html
http://commons.apache.org/fileupload/streaming.html
On Nov 27, 2:36 am, Sreekanth Nambiar <pk.sreeka...@gmail.com> wrote:
> Hi,
>
> What is the best approach to upload a file?
>
> 1. Is it mandatory to submit the form? How should i implement the Remote
> Service in this case?
>
> 2. Can i upload the file with an asynchronous call? What should be the input
> parameters to the Remote service method in this case?
>
> Can anybody help me with some sample code?
>
> Thanks
> Sreekanth
--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
No comments:
Post a Comment