Has anyone attempted file upload using Struts? I am able to upload a file but then the automatic loading of form bean data is disrupted. Can anyone show me how to accomplish both Regards SR
Hi there, Take a look at the examples that come with the Struts download. One of them shows how to upload files using Struts. Darryl
Paul McKenna
Ugly Redneck
Ranch Hand
Joined: Jul 08, 2000
Posts: 1006
posted
0
Thank you Darryl, I wish I had looked into those examples earlier. Regards SR
Mary White
Ranch Hand
Joined: Jan 27, 2003
Posts: 41
posted
0
In what sample did you find the upload usage? How do you retreive the BLOB once it's in the database?
Darryl A. J. Staflund
Ranch Hand
Joined: Oct 06, 2002
Posts: 303
posted
0
Hi Mary, It seems to me you are experiencing another problem altogether. The Struts upload example shows how to use its file upload classes to upload a file to the file system. It does not indicate how to store and retrieve files as BLOBs in a database. I won't be of much use for the latter question as I've never designed a database for use as a file repository :-) Sorry about that. Darryl
George Brown
Ranch Hand
Joined: Sep 26, 2000
Posts: 919
posted
0
You should be able to find the upload samples in the jakarta-struts-1.0.2-src package, buried somewhere under the src/upload directory. HTH.
Paul McKenna
Ugly Redneck
Ranch Hand
Joined: Jul 08, 2000
Posts: 1006
posted
0
I got an email from a fellow rancher requesting me to provide sample code related to file upload in Struts. I was able to successfully implement the file upload functionality in production and here is the code require to do so..
JSP Code: This code sets up the html form for upload requests. Note the form tag with the encoding type set to multipart-form data. Use the html:file tag for the text box that will be used to specify the file that needs to be uploaded. This will automatically provide a "Browse" button.
In your ActionForm class: The following lines are important
In the action class that will process the uploaded file:
Can we customize the 'Browse' button that comes along with struts file upload.i.e., if we want to keep a customized image("Browse"), how could we accomplish it.
Sean Sullivan
Ranch Hand
Joined: Sep 09, 2001
Posts: 427
posted
0
I built a Struts application that demonstrates file upload and file download.
Originally posted by sai kinnera: Can we customize the 'Browse' button that comes along with struts file upload.i.e., if we want to keep a customized image("Browse"), how could we accomplish it.
Hi Sai kinnera Did u able to find the answer for you question,If yes please let us know the answer.If no,Ranchers please help us.
Thanks JK
Grishma Dube
Ranch Hand
Joined: Jul 01, 2003
Posts: 273
posted
0
What exactly the commons-fileupload package do??
Can anyone provide me tutorial or more information abt it???
Grishma
Joel Espinosa
Greenhorn
Joined: Sep 09, 2005
Posts: 2
posted
0
I know how to upload and download a file stored in the server with struts, what i don't know is how to update these file, how i can reuse my ActionForm in order to make and update of the file. In my app the file is saved in postgres.
this is ganesh ,i implement ur code for uploading the file in struts, the flow is going fine,but the file is not uploaded any where. I also implented controller ,code i specified below, still the file is not getting uploaded any where.
[ June 24, 2006: Message edited by: ganesh vadivel ] [ June 24, 2006: Message edited by: ganesh vadivel ]
Merrill Higginson
Ranch Hand
Joined: Feb 15, 2005
Posts: 4864
posted
0
While the code in the above posts shows something about how to read an uploaded file, none of the posts show code to save the file on the server. If you are unfamiliar with how to write a file, This link should help. [ June 25, 2006: Message edited by: Merrill Higginson ]