Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regarding file downloading

 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have a problem in downloading a file(image files only) from the server. Actually i am reading the file using FileInputStream and BufferedInputStream and writing using OutputStream.When i click to download it is opening in IE but it is not opening in Netscape. I need to open the file directly and not to prompt for Save as / Open it from current location. For your reference my codes:
OutputStream out = response.getOutputStream();
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
response.setContentType("application/x-filler");
response.setHeader("Content-Disposition","attachment;filename="+ fileName);
int buffer = 0;
while((buffer = bis.read())!=-1)
{
out.write(buffer);
}
out.flush();
out.close();
bis.close();
please advice on the above
 
Thomas Goorden
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried setting the response MIME type directly to an image ( response.setContentType("image/jpeg") or response.setContentType("image/gif") )?
It is typical of IE to do what it thinks is most appropriate for a file type, even if you set some weird MIME type like "application/x-filler".
 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya i tried with that also. But it promts to Save as/ Open it from current location in IE, not in Netscape. My requirement is, user should not be prompted , instead open in the browser directly.when the user click the download , i am opening a small pop-up window and in that the image should be displayed..
please clarify with my requirement.
thanks
 
Peter Kristensson
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried with the correct MIME-type but without the "attatchment" clause.
Just set the Content-type and dont set any disposition.
Might work, not sure
/Peter
 
sathish kannan
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya ya thomas
its working fine .
thanks thomas
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic