当前位置: 代码迷 >> JavaScript >> java jsp servlet fileupload下传图片时获取下传图片尺寸(宽高)的代码
  详细解决方案

java jsp servlet fileupload下传图片时获取下传图片尺寸(宽高)的代码

热度:140   发布时间:2013-01-02 13:08:44.0
java jsp servlet fileupload上传图片时获取上传图片尺寸(宽高)的代码

java jsp servlet fileupload上传图片时获取上传图片尺寸(宽高)的代码

?

DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);

List items = upload.parseRequest(request);
Iterator iter = items.iterator();
while (iter.hasNext()) {
	if (!item.isFormField()) {
		BufferedImage img = javax.imageio.ImageIO.read(item.getInputStream());
    	img.getWidth()//获取宽
    	img.getHeight()//获取高
	}
}
?
  相关解决方案