我使用此代码上传文件。
out.println("<html>");
out.println("<body>");
out.print("<form action=\"/upload\" method=\"POST\" enctype=\"multipart/form-data\">");
out.print("<input name=\"file\" type=\"file\" size=\"50\">");
out.print("<input name=\"submit\" type=\"submit\" value=\"submit\">");
out.print("</form>");
out.println("</body>");
out.println("</html>");
但是,我只能使用InputStream wholeContent = request.getInputStream();
获取此信息。我想获得内容长度(如果我可以获得文件大小,那会更好)。我怎么能这样做?
------WebKitFormBoundaryNAHFVP37tCcjHi8j
Content-Disposition: form-data; name="file"; filename="1.txt"
Content-Type: text/plain
text-content here!
------WebKitFormBoundaryNAHFVP37tCcjHi8j
Content-Disposition: form-data; name="submit"
submit
------WebKitFormBoundaryNAHFVP37tCcjHi8j--