Uploading files using multipart/form-data

Posted on 2003-03-27
Medium Priority
Last Modified: 2012-05-04
I want to upload files usign a servlet through multipart/form-data. I have written code which gets the input stream and parses the top headers till the actual file contents starts and then the boundary header at the bottom. i also get the file name from the header which i am using it to store the file to the server. I am able to upload a txt file and bmp file and .java and .class files but .gif and .jpg files are not uploaded as it should be. when i upload gif or jpg file and open it both opens but the images are incompleted and blurred respectively there is no error shown when i try to open these files. When i upload a Pdf files it uploads but the pages are blank. when i upload the pdf files without parsing the contents i.e., i read the whole inputstream as byte and writting the whole stream as byte then the file is uploaded perfectly. I know there are ready codes available but i want to write one of my own. If some body can tell me what is going wrong it will be a great help for me. corrently i am reading and writting in bytes or if i could get the logic to parse the content with out disturbing the bytes so that i can upload any file perfectly i will be amazing...Thanks.
Question by:Ratanesh
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

msterjev earned 100 total points
ID: 8216257
Go to:

And search for MultipartRequest. This is a fully functional multipart parser which certanly works!
LVL 11

Assisted Solution

fargo earned 100 total points
ID: 8219660

Take a look at jspsmartupload


This is also a very good upload tool and having some sample codes on the site. It's a freeware.

If you have further questions, ask back.
thanks and regards
happy working

Expert Comment

ID: 9058461
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
LVL 15

Expert Comment

ID: 9734739
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Split between mstrjev and fargo.

Please leave any comments here within the next seven days.


EE Cleanup Volunteer

Expert Comment

ID: 11849105
please send me how to do an http post to sms/mms gateway for sending mms through pc using java.

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question