Cannot upload a whole images
Hi all
I'm coding jsp to upload the images into the blob (mysql database). Everything seems good except one thing that I cannot upload the completed images into database. I can upload images with no error but when I try to retrieve it back out browser, I've just got part of images to be displayed. below is my code. Thanks in advance
DiskFileUpload Upload = new DiskFileUpload();
Upload.setSizeMax(-1);
List items = Upload.parseRequest(request);
Iterator it = items.iterator();
while (it.hasNext()) {
FileItem fi = (FileItem)it.next();
if(!(fi.isFormField())) {
PreparedStatement pstmt = conn.prepareStatement("INSERT INTO fswar0090 (files, filesize) VALUES( ?, ?)" );
try {
pstmt.setBinaryStream(1, fi.getInputStream(), (int)fi.getSize());
pstmt.setInt( 2, (int)fi.getSize() );
pstmt.executeUpdate();
pstmt.close();
}
catch (Exception e) {
out.println("error:" + e.getMessage());
}
}
}
|