在文件上传时,怎么通过选择文件就把文件保存在服务器的临时目录中? 在文件上传时,怎么通过选择文件就把文件保存在服务器的临时目录中?能给我一段代码参考吗?急用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 public String execute() throws Exception { //实现上传 InputStream is = new FileInputStream(file); String root = ServletActionContext.getRequest().getRealPath("/upload"); System.out.println(this.getFileContentType() ); File deskFile = new File(root,this.getFileFileName()); OutputStream os = new FileOutputStream(deskFile); byte [] bytefer = new byte[400]; int length = 0 ; while((length = is.read(bytefer) )>0) { os.write(bytefer,0,length); } os.close(); is.close(); return SUCCESS; } [着急]这个项目需求如何实现? 在jsp中怎么比较值? session的有效范围 JSP中关于动态合并表格的问题 JSP的文件操作。~ 用Lucene-1.3-final为网站数据库建立索引 有问题 jsp如何实现打印报表 求可以将引入的HTML,JS等代码原封不动显示并格式化的JSP代码!! mysql安装问题 哥们们,帮帮忙 myeclipse里建的web工程编译没有问题,但不能在浏览器里打开,会出现问题(404错误)。拜托高手指点一下!!!! javaweb是干什么的
//实现上传
InputStream is = new FileInputStream(file);
String root = ServletActionContext.getRequest().getRealPath("/upload");
System.out.println(this.getFileContentType() );
File deskFile = new File(root,this.getFileFileName());
OutputStream os = new FileOutputStream(deskFile);
byte [] bytefer = new byte[400];
int length = 0 ;
while((length = is.read(bytefer) )>0)
{
os.write(bytefer,0,length);
}
os.close();
is.close();
return SUCCESS;
}