You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by David Thielen <da...@windward.net> on 2006/01/19 02:32:49 UTC

file upload via struts

Hi;

 

Is the best way to do this still FormFile and anyone have a url to a
good/correct example? (I've written tons of enterprise level java code, but
never a file upload or browse button.)

 

Thanks - dave

 

 

David Thielen

www.windwardreports.com

303-499-2544

 


Re: file upload via struts

Posted by Vikrama Sanjeeva <vi...@gmail.com>.
Hi,

 Good and complete example is here:

http://www.roseindia.net/struts/strutsfileupload.shtml

and check this too:
http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=next_topic&f=58&t=006647&go=older

At the end of the day, you need to code Java I/O for file (s) manipulation.
If you read the 1st link, then can use this piece of code for saving file.

***********************************************
   public void saveFile(InputStream in, File dst)throws IOException {

           // dst: is a destination variable; where u r going to write file
which is lready created on server.
            // in: is an inputStream of the source file that is, file from
where u will copy the contents to dst. InputStream will be open on clients
file on his machine.

            OutputStream out = new FileOutputStream(dst);

            // Transfer bytes from in to out
            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                System.out.println("writing to file and len = "+ len);
                out.write(buf, 0, len);
            }
            in.close();
            out.close();
        }

***********************************************

Hope it helps.

Bye,
Viki.


On 1/19/06, Niall Pemberton <ni...@blueyonder.co.uk> wrote:
>
> http://wiki.apache.org/struts/StrutsFileUpload
>
> Niall
>
> ----- Original Message -----
> From: "David Thielen" <da...@windward.net>
> Sent: Thursday, January 19, 2006 1:32 AM
>
>
> > Hi;
> >
> > Is the best way to do this still FormFile and anyone have a url to a
> > good/correct example? (I've written tons of enterprise level java code,
> but
> > never a file upload or browse button.)
> >
> > Thanks - dave
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: file upload via struts

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
http://wiki.apache.org/struts/StrutsFileUpload

Niall

----- Original Message ----- 
From: "David Thielen" <da...@windward.net>
Sent: Thursday, January 19, 2006 1:32 AM


> Hi;
>
> Is the best way to do this still FormFile and anyone have a url to a
> good/correct example? (I've written tons of enterprise level java code,
but
> never a file upload or browse button.)
>
> Thanks - dave



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org