• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Create directories while uploading files in Servlet

 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I am required to upload files using my web application. Using a servlet for this. And using Apache Commons - FileUpload (My favourite is the O' Reilly Multipart, but cant use it because of licensing issues).

Problem:

The file upload works fine as long as i try to upload to directories already present, but if the directories are not present and i try to create the directories, i get an 'Access Denied' Exception.

Here is the code:



and the Exception is:



Yep, i know, not the best of codes, but am concerned with the Exception at the moment.

Should i separate the tasks of making the directories and then writing to them in 2 different servlets? Will that work??
[ October 06, 2005: Message edited by: Neeraj Dheer ]
 
Neeraj Dheer
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry...my mistake...bug in the code...was trying to open a directory with FileOutputStream, not a file...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic