download multiple files types
I am using jsp servlet to upload and download 开发者_JAVA百科files.
I want to download many types of files, so I choose to download them as zip files in order not to fall in defining each type of attachment in the response, when I make upload all of files uploaded correctly, when I make download for txt and docx files they are downloaded correctly too, but when I download pdf or image files, they are not downloaded correctly, since I put them in the same folder!
when I make download for txt and docx files they are downloaded correctly too, but when I download pdf or image files, they are not downloaded correctly
Fact: .txt
and .docx
(XML!) files are text based while PDF and images are binary based.
So, it sounds much like that you read/write files using Reader
/Writer
instead of InputStream
/OutputStream
.
Fix the code accordingly. Never use Reader
/Writer
as long as you're not interested in the actual file content on a character basis. It will totally corrupt binary files. You can find a basic example of a download servlet here.
精彩评论