ssh中上传文件携带参数
2016-05-13 11:20
399 查看
@Override
public String execute() throws Exception {
String root = ServletActionContext.getServletContext().getRealPath(
"/uplpic");
File dir = new File(root);
if (dir.exists() == false) {
dir.mkdirs();
}
List<String> list = new ArrayList<String>();
for (int i = 0; i < file.size(); ++i) {
String name = fileFileName.get(i).toString();// 得到上传文件的原名称
String txt = name.substring(name.lastIndexOf(".")-1,name.length());
InputStream is = new FileInputStream(file.get(i).toString());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");// 格式化时间输出
String Rname = sdf.format(new Date());// 取得当前时间,Date()是java.util包里的,这作为真实名称
name = Rname + new Random().nextInt(10000)+txt;// 重命名文件名称,命名规则为:时间+原文件名称*/
File destFile = new File(root, name);
OutputStream os = new FileOutputStream(destFile);
byte[] buffer = new byte[400];
int length = 0;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
list.add("uplpic" + "/" + name);
is.close();
os.close();
}
for (int i = 0; i < list.size(); i++) {
modelpic.setModelKeyword(modelKeyword);
modelpic.setPicModelpic(list.get(i));
modelpic.setPicOrder(0);
modelpic.setPicStatus("0");
cbiz.save(modelpic);
}
if (list.size() > 0) {
return INPUT;
} else {
return SUCCESS;
}
}
public String execute() throws Exception {
String root = ServletActionContext.getServletContext().getRealPath(
"/uplpic");
File dir = new File(root);
if (dir.exists() == false) {
dir.mkdirs();
}
List<String> list = new ArrayList<String>();
for (int i = 0; i < file.size(); ++i) {
String name = fileFileName.get(i).toString();// 得到上传文件的原名称
String txt = name.substring(name.lastIndexOf(".")-1,name.length());
InputStream is = new FileInputStream(file.get(i).toString());
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");// 格式化时间输出
String Rname = sdf.format(new Date());// 取得当前时间,Date()是java.util包里的,这作为真实名称
name = Rname + new Random().nextInt(10000)+txt;// 重命名文件名称,命名规则为:时间+原文件名称*/
File destFile = new File(root, name);
OutputStream os = new FileOutputStream(destFile);
byte[] buffer = new byte[400];
int length = 0;
while ((length = is.read(buffer)) > 0) {
os.write(buffer, 0, length);
}
list.add("uplpic" + "/" + name);
is.close();
os.close();
}
for (int i = 0; i < list.size(); i++) {
modelpic.setModelKeyword(modelKeyword);
modelpic.setPicModelpic(list.get(i));
modelpic.setPicOrder(0);
modelpic.setPicStatus("0");
cbiz.save(modelpic);
}
if (list.size() > 0) {
return INPUT;
} else {
return SUCCESS;
}
}
相关文章推荐
- Oracle用户过期及重置密码
- 获取APP地图权限
- CLR via C# 第4版 目录
- 实时显示系统时间和改变时间格式进行计算
- 手机摄影(2)
- Q&A
- Android开发过程中手机本地日志使用
- Loadrunner脚本回放出现Vuser Terminated原因
- PHP5.3连接Oracle客户端及PDO_OCI模块的安装方法
- ImageLoader加载图片
- [Python]第二讲:2.x与3.x版本区别
- PHP函数的实现原理及性能分析
- Mac系统鼠标在移动时,指针变的很大,是什么鬼?
- Android Application与thread、stack、task、activity之间的关
- iOS8新特性——UIPresentation在转场动画中的使用
- 每日随笔记录2016-05-13_1
- Spket在Eclipse下的安装和配置(图文教程)
- css实现鼠标移入table时出现滚动条且table内容不移位
- springMVC学习之url重写:urlrewrite with tuckey UrlRewriteFilter
- 修改状态栏,电池,wifi的颜色为白色