• 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

how to upload file along with HTML form data

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
when i try to upload a file along with html form data,am using enctype="multipart/form-data" in the form tag to upload a file.but when i use enctype="multipart/form-data" am unable to get form data.its showing null values.when i remove the enctype attribute from form tag its working fine,but unable to upload the file.pls tell me what might be the reason...am geting frustated with this prob...pls help me out....

lots of thanks in advance
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

when i remove the enctype attribute from form tag its working fine,but unable to upload the file



Could you please explain as what exactly is failing.

" Its working fine ,but unable to upload a file" - then how is that working fine ?

This might be useful.
[ July 26, 2007: Message edited by: Rahul Bhattacharjee ]
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have html form values(ex:username,password,location,ph no,etc.,)and also browse file option.when i put the attribute enctype="multipart/form-data" in the form tag,the form values(ex:username,password,location,ph no,etc.,)are going as null to database but the file is getting uploaded.when i remove the "enctype" attribute from the form tag all the form values are getting stored in database but the file is not getting uploaded.how can i resolve this......

thanks for your interest
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you doing on the server side to read the multipart data coming from the browser ?
[ July 26, 2007: Message edited by: Rahul Bhattacharjee ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Multipart posts work differently from regular form posts.
You can not use request.getParameter to retrieve form parameters.

You will need to read the documentation for the upload libraries you're using to find out how to get them.
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your reply.can i have the documentation or a link regarding that so that it will be easy for me.am trying for this since 10 days but of no use..
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am preparing a page similar to naukri.so i need to get the user details(like email,phno,skillset,etc.,)along with his resume.i am storing the files in a specified path and the form values in the database...this is the theme of my work
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have already sent you the link in my first post.
You might also have a look in Javaranch's FAQ.

http://faq.javaranch.com/view?FileUpload
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
am using JDeveloper.how can i import org.apache.*;is that the only process?
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you dont mind can i have an example with a browse option to upload a file and a textbox to store the data in the database...pls,help me out...
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You have to pick an upload library and read the documentation that comes with it. Personally, I use Apache Jakarta Common's 'fileupload' which has simple examples in its documentation.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also, the article linked to by Rahul Bhattacharjee in his earlier post has some very nice code samples. Did you read it?
 
pranith nani
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i dont have tomcat installed.can i have any other way to escape the prob???
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What container are you using?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by pranith nani:
i dont have tomcat installed.



It doesn't have to be Tomcat - just use the servlet container you have. File upload is an HTTP feature - it works the same on all containers.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic