I have a simple form with enctype "multipart"; I am using this to upload an image to my server. I have two possible solutions, but neither of them are complete.
First solution:
FileItemIterator iterator = upload.getItemIterator( request );
while( iterator.hasNext() ){
FileItemStream item = iterator.next();
if( item.isFormField() ){
// store IMG
}
} // ~while( iter.hasNext() )
In this solution, I can't get the dimensions of the uploaded file, but I can get if it's a form field or not (using item.isFormField()
)
My second solution uses the Servlet 3.0 API:
for( Part part: request.getParts() ){
System.out.println( part.getSize() );
}
Here I can get the size of the uploaded image, but I can't tell whether it's a simple form field or not.
What am I missing?
What you need for help me?