日期:2014-05-19 浏览次数:21064 次
public String create() { String result = "create_failure"; this.resourceService = new ResourceService(); this.resource.setUser((User)this.session.getAttribute("user")); //取扩展名 String[] tmp = this.resource.getUpFileFileName().split("\\."); String fileType = tmp[tmp.length-1]; this.resource.setFiletype(fileType); //filePath = 上传路径 + userid +文件名 String filePath = ServletActionContext.getServletContext().getRealPath("/resource") + "/" + this.resource.getUser().getUserid() + this.resource.getUpFileFileName(); this.resource.setFilesize(this.resource.getUpFile().length()); this.resource.setPath(filePath); File target = new File(filePath); FileUploader.upLoadFile(this.resource.getUpFile(),target); if (this.resourceService.create(this.resource)) { result = "create_success"; } return result; }