上传文件,想把上传的文件放在项目根目录下面的upload文件夹下
在jsp中 String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String url = basePath+"upLoad";
File file = new File(url);
if(!file.exists()){
file.mkdir();
}upLoad文件夹无法正确创建,请帮忙!!!
在jsp中 String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String url = basePath+"upLoad";
File file = new File(url);
if(!file.exists()){
file.mkdir();
}upLoad文件夹无法正确创建,请帮忙!!!
比如:"C:\Documents and Settings\Administrator\Workspaces\MyEclipse\MBS\upload";
再加上upload
.getRealPath("/")
+ "upload";// 上传文件保存的目录
比如:"C:\Documents and Settings\Administrator\Workspaces\MyEclipse\MBS\upload";