You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Narayana S <na...@gmail.com> on 2008/10/21 08:32:00 UTC

File Upload into database

Hi,

        i am new to struts 2, want to use file upload control. once the file
is uploaded i want to store its content into the database, i didn't work on
the file upload previously also. so any one can please tell me the best way
to access the uploaded file and store that into database? any links or
information on how can this be achevied will help me.

thanks in advance.

Re: File Upload into database

Posted by Mead Lai <la...@gmail.com>.
There is Example in the "show-case" app, which is contain with the struts
Full Releases package.
simplely,
U add into Action:
    private String uploadContentType;
    private String uploadFileName;
    private File upload;
and use <s:file name="upload"/> Tag in the jsp Page.
U can get file just call upload field.

On Tue, Oct 21, 2008 at 2:32 PM, Narayana S <na...@gmail.com> wrote:

> Hi,
>
>        i am new to struts 2, want to use file upload control. once the file
> is uploaded i want to store its content into the database, i didn't work on
> the file upload previously also. so any one can please tell me the best way
> to access the uploaded file and store that into database? any links or
> information on how can this be achevied will help me.
>
> thanks in advance.
>



-- 
BestRegards,
Mead
http://yayisoft.com

Joan Rivers  - "The first time I see a jogger smiling, I'll consider it."

Re: File Upload into database

Posted by Narayana S <na...@gmail.com>.
now it is working. i could pass the values. i have added these two
interceptors to my stack as described in the link given.
i need to start working on strong this file content to data base blob field.
(lets see ...)

                <interceptor-ref name="fileUpload" />
                <interceptor-ref name="basicStack"/>

http://cwiki.apache.org/WW/file-upload-interceptor.html

Thanks everyone.


On Tue, Oct 21, 2008 at 4:25 PM, Narayana S <na...@gmail.com> wrote:

> yes
>
> <s:form action="CreateIssue" theme="qxhtml" method="POST"
> enctype="multipart/form-data">
>
> this is the form tag...
>
>
> On Tue, Oct 21, 2008 at 4:25 PM, Ketil Holden <Ke...@invenia.no>wrote:
>
>> Have you set enctype on the form element?
>>
>> Like this:
>> <s:form action="action" enctype="multipart/form-data" ...
>>
>> ??
>>
>>
>> -----Original Message-----
>> From: Narayana S [mailto:narayanasgs1@gmail.com]
>> Sent: 21. oktober 2008 12:31
>> To: Struts Users Mailing List
>> Subject: Re: File Upload into database
>>
>> Hi Thanks for your reply,
>>
>>            but when i submit my form it is not setting value for the
>> upload
>> properties. this is how my code is ...
>> -- in jsp
>> <s:file name="upload" label="Attachment"/>
>> -- in action
>> private String uploadContentType;
>> private String uploadFileName;
>> private File upload;
>>
>> and getter setters for these properties. i am using struts 2.1.2. where i
>> am
>> still missing? remaining properties of the form are getting set, only this
>> is not working :(
>> help me
>>
>> On Tue, Oct 21, 2008 at 12:14 PM, ManiKanta G <go...@gmail.com> wrote:
>>
>> > http://struts.apache.org/2.x/docs/how-do-we-upload-files.html
>> >
>> > have some info to start.
>> >
>> > ManiKanta
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>

Re: File Upload into database

Posted by Narayana S <na...@gmail.com>.
yes

<s:form action="CreateIssue" theme="qxhtml" method="POST"
enctype="multipart/form-data">

this is the form tag...

On Tue, Oct 21, 2008 at 4:25 PM, Ketil Holden <Ke...@invenia.no>wrote:

> Have you set enctype on the form element?
>
> Like this:
> <s:form action="action" enctype="multipart/form-data" ...
>
> ??
>
>
> -----Original Message-----
> From: Narayana S [mailto:narayanasgs1@gmail.com]
> Sent: 21. oktober 2008 12:31
> To: Struts Users Mailing List
> Subject: Re: File Upload into database
>
> Hi Thanks for your reply,
>
>            but when i submit my form it is not setting value for the upload
> properties. this is how my code is ...
> -- in jsp
> <s:file name="upload" label="Attachment"/>
> -- in action
> private String uploadContentType;
> private String uploadFileName;
> private File upload;
>
> and getter setters for these properties. i am using struts 2.1.2. where i
> am
> still missing? remaining properties of the form are getting set, only this
> is not working :(
> help me
>
> On Tue, Oct 21, 2008 at 12:14 PM, ManiKanta G <go...@gmail.com> wrote:
>
> > http://struts.apache.org/2.x/docs/how-do-we-upload-files.html
> >
> > have some info to start.
> >
> > ManiKanta
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

RE: File Upload into database

Posted by Ketil Holden <Ke...@invenia.no>.
Have you set enctype on the form element?

Like this:
<s:form action="action" enctype="multipart/form-data" ...

??


-----Original Message-----
From: Narayana S [mailto:narayanasgs1@gmail.com]
Sent: 21. oktober 2008 12:31
To: Struts Users Mailing List
Subject: Re: File Upload into database

Hi Thanks for your reply,

            but when i submit my form it is not setting value for the upload
properties. this is how my code is ...
-- in jsp
<s:file name="upload" label="Attachment"/>
-- in action
private String uploadContentType;
private String uploadFileName;
private File upload;

and getter setters for these properties. i am using struts 2.1.2. where i am
still missing? remaining properties of the form are getting set, only this
is not working :(
help me

On Tue, Oct 21, 2008 at 12:14 PM, ManiKanta G <go...@gmail.com> wrote:

> http://struts.apache.org/2.x/docs/how-do-we-upload-files.html
>
> have some info to start.
>
> ManiKanta
>

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


Re: File Upload into database

Posted by Narayana S <na...@gmail.com>.
Hi Thanks for your reply,

            but when i submit my form it is not setting value for the upload
properties. this is how my code is ...
-- in jsp
<s:file name="upload" label="Attachment"/>
-- in action
private String uploadContentType;
private String uploadFileName;
private File upload;

and getter setters for these properties. i am using struts 2.1.2. where i am
still missing? remaining properties of the form are getting set, only this
is not working :(
help me

On Tue, Oct 21, 2008 at 12:14 PM, ManiKanta G <go...@gmail.com> wrote:

> http://struts.apache.org/2.x/docs/how-do-we-upload-files.html
>
> have some info to start.
>
> ManiKanta
>

Re: File Upload into database

Posted by ManiKanta G <go...@gmail.com>.
http://struts.apache.org/2.x/docs/how-do-we-upload-files.html

have some info to start.

ManiKanta