如何修改文件上传时的路径
package photo;
import java.io.File;
import
java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import
javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import
org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
/**
*
* @author zhupan
*
*/
public class Upload extends HttpServlet {
/**
*
*/
private static final long serialVersionUID = 1L;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws
ServletException,
IOException {
response.setContentType( "text/html; charset=GB2312 ");
PrintWriter out = response.getWriter();
try {
DiskFileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload sevletFileUpload = new ServletFileUpload(factory);
// 设置允许用户上传文件大小,单位:字节,这里设为2m
sevletFileUpload.setSizeMax(2 * 1024 * 1024);
// 设置最多只允许在内存中存储的数据,单位:字节
factory.setSizeThreshold(4096);