dcsimg
Downloading an attachment (Urgent Help needed)
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Rohan_Chhatre
Posted On:   Monday, February 17, 2003 02:24 AM

The downloaded file is of same size as that of the original but still it does not open. Works fine when downloaded on Linux but gives problem with Windows. Is it a EOF problem or what? The code is.. filename = p.getFileName(); if(p.getFileName() != null) { if(attachedFile.equals(p.getFileName())) { response.setContentType(p.getContentType()); response.setHeader("Content-Disposition","attachment; filename="" +p.getFileName()+"""); BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); BufferedInputStream in = new BufferedInputStream(p.getInputStream()); int c = in   More>>

The downloaded file is of same size as that of the original but still it does not open. Works fine when downloaded on Linux but gives problem with Windows. Is it a EOF problem or what? The code is..


filename = p.getFileName();

if(p.getFileName() != null)

{

if(attachedFile.equals(p.getFileName()))

{

response.setContentType(p.getContentType());

response.setHeader("Content-Disposition","attachment; filename="" +p.getFileName()+""");

BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());

BufferedInputStream in = new BufferedInputStream(p.getInputStream());


int c = in.read();

while(c != -1)

{

out.write(c);

c = in.read();

}

out.flush();

out.close();

in.close();

}

}



Please let me know where the problem is..
-Rohan.

   <<Less
About | Sitemap | Contact