public String upload(){
HttpSession session=ActionContext.getActionContext().getMap().getSession();
String filepath=session.getServletContext().getRealPath("/")+"image/";
File f=new File(filepath);
if(!f.exists()){
f.mkdir();
}
f=new File(filepath+"/"+System.currentTimeMillis()+".jpg");
try {
FileInputStream fis=new FileInputStream(file);
FileOutputStream fos=new FileOutputStream(f);
byte [] data=new byte[1024];
while((fis.read(data, 0, 1024))!=-1){
fos.write(data, 0, 1024);
}
fos.flush();
fos.close();
fis.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "add";
}
分享到:
相关推荐
el-upload多文件一次性上传(携带json),自定义上传事件(手动上传),不使用action属性上传
文件上传一直是B/S结构中很重要的一项功能,在java中并没有很好的实现文件上传的类包,因此出现了一些开源的组件,Smartupload ,commons-fileupload,还有国内的一个"牛人"的(不好意思叫不上名字来),这几个组件中...
struts2文件上传与下载, <s:form name="Myform" action="/fileManage/upload" method="post" enctype="multipart/form-data" theme="simple" > <s:fielderror></s:fielderror> 文件"></s:file> ...
* PHP与Web页面交互 -----文件上传和下载 课程内容 文件上传 文件下载 一、文件上传 文件上传从本质上讲,就是将表单数据的一部分提交到服务器端。只是因为其数据类型(字节流或二进制流)不一样,从而导致在服务器...
* PHP与Web页面交互 -----文件上传和下载 课程内容 文件上传 文件下载 一、文件上传 文件上传从本质上讲,就是将表单数据的一部分提交到服务器端。只是因为其数据类型(字节流或二进制流)不一样,从而导致在服务器...
ckeditor文件上传功能,附图片上传示例,java程序及返回结果。 strut配置 <action name="uploadCKEditorImage" class="com.usmartone.system.attachs.action.UploadAction"> <param name="allowedTypes">image/bmp...
FTP上传,删除,下载文件的工具类(可供Action/Controller层使用) FtpUtil.uploadFileFromProduction(hostname, port, username, password, pathname, filename, originfilename);
近日,致远OA ajaxAction 文件上传漏洞利用代码披露,由于致远OA旧版本中某些接口存在未授权访问,以及部分函数过滤不足,攻击者通过构造恶意请求,可在无
编写html文件在classpath下的static中 <!... 文件上传 <form action="fileUploadController" method="post" enctype="multipart/form-data"> 上传文件:<input type="file" name="filename"/> </html>
Struts 2是通过Commons FileUpload文件上传。Commons FileUpload通过将HTTP的数据保存到临时文件夹,然后Struts使用fileUpload拦截器将文件绑定到Action的实例中。从而我们就能够以本地文件方式的操作浏览器上传的...
Struts 2是通过Commons FileUpload文件上传。Commons FileUpload通过将HTTP的数据保存到临时文件夹,然后Struts使用fileUpload拦截器将文件绑定到Action的实例中。从而我们就能够以本地文件方式的操作浏览器上传的...
项目需求是多个文件上传,在一次请求中完成,而ElementUI的上传组件是每个文件发一次上传请求,因此我们借助FormData的格式向后台传文件组 html代码 <div class="upload-file"> accept=".xlsx" ref="upload...
包含了Struts+hibernate文件,上传所用到的主要jar,以及处理的action
本文实例讲述了Django框架文件上传与自定义图片上传路径、上传文件名操作。分享给大家供大家参考,具体如下: 文件上传 1、创建上传文件夹 在static文件夹下创建uploads用于存储接收上传的文件 在settings中配置, ...
-- 系统常量定义,定义上传文件字符集编码 --> <constant name="struts.i18n.encoding" value="UTF-8"></constant> <!-- 系统常量定义,定义上传文件临时存放路径 --> ...
上传文件 </head> <form action="index.jsp?flag=1" method="post" enctype="multipart/form-data" name="form1"> 上传"> </form></td> if(null != request.getParameter("flag")){ SmartUpload ...
flash flex actionscript as3 多文件上传组件
struts2中的文件上传和下载: 1.首先导入commons-fileupload-1.2.1.jar和commons-io-1.4.jar两个jar包 2.其次JSP页面中的文件上传控件所在的form必须设置属性enctype="multipart/form-data" 3.再次,struts2中...
java上传文件的时候, 当我们在action中截获文件, 其实已经晚了, 这个时候 文件的临时文件已经传到服务器上了, 所以 本人利用apache的监听类 做了文件上传 带进度条, 大家参考