package cn.lzu.xxaq;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import javax.swing.ImageIcon;
import org.apache.commons.io.FileUtils;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class UploadImage extends ActionSupport {
private static final int BUFFER_SIZE = 16 * 1024;
private File image;
private String imageFileName;
private String imageContentType;
private int imageHeigth;
private int imageWidth;
/**
* @param image
* the image to set
*/
public void setImage(File image) {
this.image = image;
}
/**
* @return the image
*/
public File getImage() {
return image;
}
/**
* @param imageFileName
* the imageFileName to set
*/
public void setImageFileName(String imageFileName) {
this.imageFileName = imageFileName;
}
/**
* @return the imageFileName
*/
public String getImageFileName() {
return imageFileName;
}
/**
* @param imageContentType
* the imageContentType to set
*/
public void setImageContentType(String imageContentType) {
this.imageContentType = imageContentType;
}
/**
* @return the imageContentType
*/
public String getImageContentType() {
return imageContentType;
}
private static String getExtention(String fileName) {
int pos = fileName.lastIndexOf(".");
return fileName.substring(pos);
}
public String execute() {
imageFileName = new Date().getTime() + getExtention(imageFileName);
File imageFile = new File(ServletActionContext.getServletContext()
.getRealPath("/images")
+ "/" + imageFileName);
System.out.println(imageFile.getPath());
try {
FileUtils.copyFile(image, imageFile);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ImageIcon bi=new ImageIcon(imageFile.getPath());
System.out.println(bi.getIconHeight()+" "+bi.getIconWidth());
setImageHeigth(bi.getIconHeight());
setImageWidth(bi.getIconWidth());
return SUCCESS;
}
/**
* @param imageHeigth the imageHeigth to set
*/
public void setImageHeigth(int imageHeigth) {
this.imageHeigth = imageHeigth;
}
/**
* @return the imageHeigth
*/
public int getImageHeigth() {
return imageHeigth;
}
/**
* @param imageWidth the imageWidth to set
*/
public void setImageWidth(int imageWidth) {
this.imageWidth = imageWidth;
}
/**
* @return the imageWidth
*/
public int getImageWidth() {
return imageWidth;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
struts2结合jquery剪切图片.rar (31个子文件)
参数介绍.png 29KB
JqueryImage
.project 1KB
.mystrutsdata 240B
.mymetadata 306B
src
cn
lzu
xxaq
ImageUtils.java 2KB
User.java 584B
chapThree.xml 588B
CropImage.java 2KB
UploadImage.java 2KB
struts.xml 295B
WebRoot
WEB-INF
classes
cn
lzu
xxaq
User.class 1020B
ImageUtils.class 2KB
chapThree.xml 588B
CropImage.class 3KB
UploadImage.class 3KB
struts.xml 295B
lib
web.xml 963B
index.jsp 829B
images
upload_image.jsp 3KB
jcrop
jquery.Jcrop.js 25KB
jquery.Jcrop.css 748B
demos.css 558B
jquery.min.js 56KB
Jcrop.gif 329B
META-INF
MANIFEST.MF 36B
show_image.jsp 335B
.myeclipse
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.jdt.core.prefs 330B
org.eclipse.wst.jsdt.ui.superType.name 6B
.jsdtscope 500B
.classpath 463B
共 31 条
- 1
资源评论
- wzaihuni2013-03-16这是我下载唯一一个能用的
- shishifeitian2012-12-15还不错,应该控制一下初始图片大小.
- lzm123462012-11-23大小规定下,可能会好点
- jinshiyi5882013-01-31其他不过就是上传后图片大小会有点奇怪,不知道怎么解决
- happytaocool2013-02-14源码确实不错,可是图片的大小没法变小啊
RSun01
- 粉丝: 4
- 资源: 7
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功