在java上载了一个视频文件,但文件大小为零

时间:2016-06-14 06:25:03

标签: java jsp servlets video

我的Servlet

private static final String SAVE_DIR = "videoFiles";
Part vidFilePart = request.getPart("vidinput");
String vidFileName = request.getParameter("vidfilename");

 String appPath = request.getServletContext().getRealPath("");
            // constructs path of the directory to save uploaded file
            String savePath = appPath + File.separator + SAVE_DIR;

            File fileSaveDir = new File(savePath);
            if (!fileSaveDir.exists()) {
                fileSaveDir.mkdir();
            }

            for (Part part : request.getParts()) {
                part.write(savePath + File.separator + vidFileName);
            }

            session.setAttribute("vidsessmessage", "Video Has Been Uploaded Successfully");
            response.sendRedirect("videos.jsp");

一切正常我被重定向到响应并且videoFiles中有一个视频文件但是当试图上传一个12 MB的文件时,结果文件只有12个字节。这里有什么问题?

0 个答案:

没有答案