File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Uploading File

 
arun prasad
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1561
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sean MacLean
author
Ranch Hand
Posts: 621
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any idea how to get jspsmart to save the file as a different name from the one it *was* called?
 
Carl Parrish
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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());
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic