Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File Uploading

 
Maryam Nouhnejad
Ranch Hand
Posts: 39
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,

I'm writing a web photo gallery project & I should use file uploading in order to upload the photos somewhere in the server-side.
But I'm not sure exactly how I should do this. So far I have created a jsp file (SelectFile.jsp) & written this peice of code in that :

<form action=http://localhost:8200/FileUploading/Upload.jsp enctype="multipart/form-data" method="post">
<input type=file name=file_name>
<br>
<input type=submit value=upload>
</form>


In Upload.jsp I make a bean object using the class below (UploadTheFile.java) and call its method.


Here is that method :

public void doUpload(HttpServletRequest request) throws IOException
{

ImageWriter printW = new ImageWriter(new BufferedImage(new FileWriter("image")));

ServletInputStream in = request.getInputStream();

int i = in.read();

while(i!=-1)
{

printW.print( (char) i);

i = in.read();

}

printW.close();
}


thanks in advance,

Maryam
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at this entry in our servets faq.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic