主题:上传文件容量大小以及路径问题
下面是用java servlet写的关于文件上传的代码
我测试了一下,发觉,可以上传文件大小在12M左右,上传到的地方应该是默认的地方吧(D:\tomcat\bin\).
我想用它上传30M左右的文件,路径也想改变一下,比如D:\或E:\都行,我不知道怎么修改?
请帮帮忙,谢谢了!!
UploadFileServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class UploadFileServlet extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException{
final int NONE=0;
final int DATAHEADER=1;
final int FILEDATA=2;
final int FIELDDATA=3;
int totalbytes=req.getContentLength();
byte[] b=new byte[totalbytes];
String contentType=req.getContentType();
String fieldname="";
String fieldvalue="";
String filename="";
String boundary="";
String lastboundary="";
int fileSize=0;
Hashtable formfields=new Hashtable();
int pos=contentType.indexOf("boundary=");
String fileID;
if(pos!=-1){
pos+="boundary=".length();
boundary="--"+contentType.substring(pos);
lastboundary=boundary+"--";
}
int state=NONE;
我测试了一下,发觉,可以上传文件大小在12M左右,上传到的地方应该是默认的地方吧(D:\tomcat\bin\).
我想用它上传30M左右的文件,路径也想改变一下,比如D:\或E:\都行,我不知道怎么修改?
请帮帮忙,谢谢了!!
UploadFileServlet.java
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
public class UploadFileServlet extends HttpServlet{
public void doPost(HttpServletRequest req,HttpServletResponse res)
throws ServletException,IOException{
final int NONE=0;
final int DATAHEADER=1;
final int FILEDATA=2;
final int FIELDDATA=3;
int totalbytes=req.getContentLength();
byte[] b=new byte[totalbytes];
String contentType=req.getContentType();
String fieldname="";
String fieldvalue="";
String filename="";
String boundary="";
String lastboundary="";
int fileSize=0;
Hashtable formfields=new Hashtable();
int pos=contentType.indexOf("boundary=");
String fileID;
if(pos!=-1){
pos+="boundary=".length();
boundary="--"+contentType.substring(pos);
lastboundary=boundary+"--";
}
int state=NONE;