日期:2014-05-19  浏览次数:21046 次

音频文件上传之后播放不了的怎么办?
把文件名改了一下
Java code

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;
    }



------解决方案--------------------
我也是