• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Uploading File

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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());
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic