使用SmartUpload上传文件不成功

来源:3-1 使用SmartUpload实现文件批量上传

乡下人2

2015-10-27 11:55

使用SmartUpload上传文件没有报错,但save时返回的值是0,为什么?

SmartUpload su=new SmartUpload();

su.initialize(getServletConfig(), request, response);

su.setMaxFileSize(1024*1024*10);

su.setTotalMaxFileSize(1024*1024*100);

su.setAllowedFilesList("jpg,jpeg,bmp,png,gif");

String saveFilePath=getServletContext().getRealPath("/")+"uploadFile";

try {

su.upload();

File path=new File(saveFilePath);

if(!path.exists()){

path.mkdir();

}

int uploadCount=su.save(saveFilePath);

request.getSession().setAttribute("result", "上传成功"+uploadCount);

response.sendRedirect("collectIdea.jsp");


写回答 关注

3回答

  • kekeli
    2016-08-18 10:12:33

    同问!!!

  • 星战情缘
    2016-06-01 18:34:38

    我也是,怎么解决啊!

  • luckyforever
    2016-03-19 23:28:47

    使用SmartUpload上传文件没有报错,但save时返回的值是0,为什么?

    SmartUpload su=new SmartUpload();

    su.initialize(getServletConfig(), request, response);

    su.setMaxFileSize(1024*1024*10);

    su.setTotalMaxFileSize(1024*1024*100);

    su.setAllowedFilesList("jpg,jpeg,bmp,png,gif");

    String saveFilePath=getServletContext().getRealPath("/")+"uploadFile";

    try {

    su.upload();

    File path=new File(saveFilePath);

    if(!path.exists()){

    path.mkdir();

    }

    int uploadCount=su.save(saveFilePath);

    request.getSession().setAttribute("result", "上传成功"+uploadCount);

    response.sendRedirect("collectIdea.jsp");


Java中的文件上传下载

由简入深,轻松实现文件上传下载功能及相关框架的使用

77397 学习 · 337 问题

查看课程

相似问题