GeeCON Prague 2014*
The moose likes JSP and the fly likes Uploading File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "Uploading File" Watch "Uploading File" New topic
Author

Uploading File

arun prasad
Greenhorn

Joined: Jun 16, 2002
Posts: 7
I am using enctype="multipart/form-data" in the form and file form element,when im getting this in the JSP its working perfectly fine.
If i add any other form elements like text or any other im not able to get other form elements value in the server-side after submission.
I am using Tomcat/JSP,also tried in JRun4.0 there also it failed
Can someone plz help me on this.
bye
arun
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi arun.
I think you are experiencing the same problem I had, posted here.
Now I'm using jspsmart and it is working pretty well.
you can download jspsmart at www.jspsmart.com (JSPSmartUpload).
cheers


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Sean MacLean
author
Ranch Hand

Joined: Nov 07, 2000
Posts: 621
If you use mutltipart for on element then all of your data will be sumbitted as multipart. This means that you have to parse the boundry markers and convert each html form element individually (i.e. request.getParameter() won't work). You can use the O'reilly packages since they have a nice multipart request wrapper class but you might want to check out Struts, as well. Within this framework, multipart (and file uploads) are handled in the friendliest way I've seen to date.
Sean
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Any idea how to get jspsmart to save the file as a different name from the one it *was* called?
Carl Parrish
Ranch Hand

Joined: May 03, 2002
Posts: 60
Okay right now this is working for me. But it seems like I'm first uploading all of the files to my server then renaming. Is there a way to do this in one step?
// Upload
mySmartUpload.upload();

// Save the files with new file names in a virtual path of the web server
try {

count = mySmartUpload.save("/upload/", mySmartUpload.SAVE_VIRTUAL);
for(int i=0; i < mySmartUpload.getFiles().getCount(); i++)
{
ext = mySmartUpload.getFiles().getFile(i).getFileExt();
mySmartUpload.getFiles().getFile(i).saveAs("/upload/"+fileName +"_"+ i +"."+ext,1);


}
} catch (Exception e){

out.println("<b>Wrong selection : </b>" + e.toString());
 
GeeCON Prague 2014
 
subject: Uploading File