You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by PEGASUS84 <pe...@hotmail.it> on 2009/04/28 19:25:09 UTC

file upload

please helm me
i must write a code for uploading file in a directory of the server.
i just try some example but i'm failed.
can someone give me the code to upluoad file
when i try i received this message
java.lang.RuntimeException: Unable to load bean
org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) -
[unknown location]

-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23282289.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: file upload

Posted by Burton Rhodes <bu...@gmail.com>.
I think the File class in the Java API would be a good place to start.
Just a guess though.

On 4/28/09, PEGASUS84 <pe...@hotmail.it> wrote:
>
>
> excuse me
> has some one the code to save the upload file in a specific directory?
> --
> View this message in context:
> http://www.nabble.com/file-upload-tp23282289p23286968.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

-- 
Sent from my mobile device

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


[OT] Re: file upload

Posted by Dave Newton <ne...@yahoo.com>.
dusty wrote:
> In case you have not guessed, asking someone to just "give me code" is not
> the best policy on any forum/mailing list.  You can either a) use Google to
> find someone who has posted code b) Learn to do it yourself.   Either way
> its not really a Struts related question.....
> 
> All that said, try this although I fear it will only cause more problems
> than it will help you:

...

Commons IO.

Dave


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


Re: file upload

Posted by dusty <du...@yahoo.com>.
In case you have not guessed, asking someone to just "give me code" is not
the best policy on any forum/mailing list.  You can either a) use Google to
find someone who has posted code b) Learn to do it yourself.   Either way
its not really a Struts related question.....

All that said, try this although I fear it will only cause more problems
than it will help you:

    private void saveFile(File file, String savePath, String fileName)
throws CourseResourceException{
        File dirPath = new File(savePath);
        if (!dirPath.exists()) {
            dirPath.mkdirs();
        }
        try{
        //retrieve the file data
        InputStream stream = new FileInputStream(file);

        //write the file to the file specified
        OutputStream bos = new FileOutputStream(savePath + File.separator +
fileName);
        int bytesRead;
        byte[] buffer = new byte[8192];
        while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
            bos.write(buffer, 0, bytesRead);
        }
        bos.close();
        stream.close();
        }catch(Exception e){
            throw new CourseResourceException("Could not save file to file
system.",e);
        }
    }


PEGASUS84 wrote:
> 
> 
> excuse me
> has some one the code to save the upload file in a specific directory?
> 

-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23290304.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: file upload

Posted by Dave Newton <ne...@yahoo.com>.
PEGASUS84 wrote:
> has some one the code to save the upload file in a specific directory?

Copy the file to the directory you want.

Dave

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


Re: file upload

Posted by PEGASUS84 <pe...@hotmail.it>.

excuse me
has some one the code to save the upload file in a specific directory?
-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23286968.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: file upload

Posted by Burton Rhodes <bu...@gmail.com>.
I believe that question has been asked... and answered...  Google is
your friend.

http://www.mail-archive.com/user@struts.apache.org/msg86775.html


On Wed, Apr 29, 2009 at 8:40 AM, PEGASUS84 <pe...@hotmail.it> wrote:
>
> thanks.
> but i've now a new problem: when i upload my file i received this message
> "the request was rejected because its size (3571443) exceeds the configured
> maximum (2097152)" now i set in the interceptor-ref name file upload this
> param:
> <interceptor-ref name="fileUpload">
>                 10485760
>                </interceptor-ref>
> for 10MB but it doesn't work
> can some one help me?
> --
> View this message in context: http://www.nabble.com/file-upload-tp23282289p23295870.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: file upload

Posted by PEGASUS84 <pe...@hotmail.it>.
thanks.
but i've now a new problem: when i upload my file i received this message
"the request was rejected because its size (3571443) exceeds the configured
maximum (2097152)" now i set in the interceptor-ref name file upload this
param:
<interceptor-ref name="fileUpload">
                 10485760
                </interceptor-ref>
for 10MB but it doesn't work
can some one help me?
-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23295870.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: file upload

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Sorry, my copy & paste mistake. That file is of course in the core.

Take a look at this: http://struts.apache.org/2.1.6/docs/file-upload.html

Nils-H

On Tue, Apr 28, 2009 at 7:37 PM, PEGASUS84 <pe...@hotmail.it> wrote:
>
> no where is ths file
>
> Nils-Helge Garli wrote:
>>
>> Do you have a jar with the
>> org.apache.struts2.dispatcher.multipart.MultiPartRequest class
>> anywhere in your classpath?
>>
>> Nils-H
>>
>> On Tue, Apr 28, 2009 at 7:25 PM, PEGASUS84 <pe...@hotmail.it> wrote:
>>>
>>> please helm me
>>> i must write a code for uploading file in a directory of the server.
>>> i just try some example but i'm failed.
>>> can someone give me the code to upluoad file
>>> when i try i received this message
>>> java.lang.RuntimeException: Unable to load bean
>>> org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) -
>>> [unknown location]
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/file-upload-tp23282289p23282289.html
>>> Sent from the Struts - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/file-upload-tp23282289p23282574.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: file upload

Posted by Dave Newton <ne...@yahoo.com>.
PEGASUS84 wrote:
> no where is ths file

S2 file uploading requires commons-io and commons-fileupload (by default).

Dave


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


Re: file upload

Posted by PEGASUS84 <pe...@hotmail.it>.
no where is ths file

Nils-Helge Garli wrote:
> 
> Do you have a jar with the
> org.apache.struts2.dispatcher.multipart.MultiPartRequest class
> anywhere in your classpath?
> 
> Nils-H
> 
> On Tue, Apr 28, 2009 at 7:25 PM, PEGASUS84 <pe...@hotmail.it> wrote:
>>
>> please helm me
>> i must write a code for uploading file in a directory of the server.
>> i just try some example but i'm failed.
>> can someone give me the code to upluoad file
>> when i try i received this message
>> java.lang.RuntimeException: Unable to load bean
>> org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) -
>> [unknown location]
>>
>> --
>> View this message in context:
>> http://www.nabble.com/file-upload-tp23282289p23282289.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23282574.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: file upload

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Do you have a jar with the
org.apache.struts2.dispatcher.multipart.MultiPartRequest class
anywhere in your classpath?

Nils-H

On Tue, Apr 28, 2009 at 7:25 PM, PEGASUS84 <pe...@hotmail.it> wrote:
>
> please helm me
> i must write a code for uploading file in a directory of the server.
> i just try some example but i'm failed.
> can someone give me the code to upluoad file
> when i try i received this message
> java.lang.RuntimeException: Unable to load bean
> org.apache.struts2.dispatcher.multipart.MultiPartRequest (jakarta) -
> [unknown location]
>
> --
> View this message in context: http://www.nabble.com/file-upload-tp23282289p23282289.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: file upload

Posted by Dave Newton <ne...@yahoo.com>.
PEGASUS84 wrote:
> thanks now thw action works but 
> please send me a right code to make the uploadfile in a specify directory of
> the server because the code wich i try doesn't work

Copy the file to the directory you want.

Dave



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


Re: file upload

Posted by PEGASUS84 <pe...@hotmail.it>.
thanks now thw action works but 
please send me a right code to make the uploadfile in a specify directory of
the server because the code wich i try doesn't work
-- 
View this message in context: http://www.nabble.com/file-upload-tp23282289p23282922.html
Sent from the Struts - User mailing list archive at Nabble.com.


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