Hello twittwit and others,

I've been trying to implement file upload for days in my application.
It may looks stupid but I really don't understand how it works.
I have few questions:
- If I want to use the same code as twittwit where should I place it?
in my client folder or server folder? should I add something else in
my web.xml and project.gwt.xml files?

I'm completely lost, please help me!

On Jul 18, 10:15 am, twittwit <[email protected]> wrote:
> perfect! thanks Manuel!
> common-fileupload is great!
> On Jul 18, 8:51 am, Manuel Carrasco <[email protected]>
> wrote:
>
>
>
> > filename = item.getName();
>
> > On Sat, Jul 18, 2009 at 12:27 AM, twittwit <[email protected]> wrote:
>
> > > ok thank you. i found the answer:
>
> > > public class MyFormHandler extends HttpServlet{
> > >    public void doPost(HttpServletRequest request, HttpServletResponse
> > > response)  throws ServletException, IOException {
> > >        ServletFileUploadupload= new ServletFileUpload();
>
> > >        try{
> > >            FileItemIterator iter =upload.getItemIterator(request);
>
> > >            while (iter.hasNext()) {
> > >                FileItemStream item = iter.next();
>
> > >                String name = item.getFieldName();
> > >                InputStream stream = item.openStream();
>
> > >                // Process the input stream
> > >                FileOutputStream out = new FileOutputStream
> > > ("example.csv");
> > >                //ByteArrayOutputStream out = new ByteArrayOutputStream
> > > ();
> > >                int len;
> > >                byte[] buffer = new byte[8192];
> > >                while ((len = stream.read(buffer, 0, buffer.length)) !
> > > = -1) {
> > >                    out.write(buffer, 0, len);
> > >                }
> > > //.......
>
> > >            }
> > >        }
> > >        catch(Exception e){
> > >            e.printStackTrace();
> > >        }
>
> > >    }
>
> > > }
>
> > > however, how can i extract the name of the csv file(client side) so
> > > that the csv file in my server can have the same name?
> > > thanks!!
>
> > > On Jul 18, 12:19 am, Manuel Carrasco <[email protected]>
> > > wrote:
> > > > In the dialog between the browser and the server, the client sends a
> > > > multipart/form-data request and there is more information besides the
> > > file
> > > > content, like form elements values, boundary tags, etc.
>
> > > > I recommend you to use apache commons-fileupload library to handle
> > > > multipart/form-data request in your servlets.
>
> > > > On Fri, Jul 17, 2009 at 11:44 PM, imgnik <[email protected]> wrote:
>
> > > > > hi all,
>
> > > > > i posted a question about fileupload here
>
> > > > >http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa.
> > > ..
> > > > > but i think i didn't phrase my question correctly. so gonna do another
> > > > > attempt.
>
> > > > > I tried to use agwtfileupload widget to send a csv file to the
> > > > > server. and at the server i will write it as a file (for other usage)
> > > > > it by doing : (where request is the httpservletrequest and bw is the
> > > > > bufferedwriter)
>
> > > > >  BufferedReader r = request.getReader();
> > > > >          while((thisread= r.readLine())!=null){
>
> > > > >                  bw.write(thisread);
>
> > > > >          }
> > > > >      bw.close();
> > > > >          }
> > > > >          catch(Exception e1){}
>
> > > > > however, i realised that the csv file send out contains :
>
> > > > > ------WebKitFormBoundaryN8Z6DOy7DqEWTwtLContent-Disposition: form-
> > > > > data; name="uploadFormElement"; filename="first.csv"Content-Type:
> > > > > application/octet-streamBank
>
> > > > > which results in the file created not the same as the fileupload.
> > > > > I might be wrong in my analysis. can someone advice me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to