if (null != this.getPhotoFile()) {
// 从画面上取得图片文件
File files = this.getPhotoFile();
// 文件名 = 文件名 + 日期
photoFileFileName = new Date().getTime() + photoFileFileName.trim();
String path = ServletActionContext.getServletContext().getRealPath("/");
if (!path.endsWith("\\")) {
path = path + "\\";
}
String savePath = path + "\\UploadImages\\";
// 判断保存用文件夹是否存在
mkdir(savePath);
// 保存用的数据流生成
FileOutputStream fos = null;
FileInputStream fis = null;
try {
// 保存用的数据流生成
fos = new FileOutputStream(savePath + photoFileFileName);
System.out.println(savePath + photoFileFileName);
// 保存文件
fis = new FileInputStream(files);
byte[] buffer = new byte[BUFFER_SIZE];
int len = 0;
while ((len = fis.read(buffer)) > 0) {
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载
- 1
- 2
- 3
- 4
前往页