smartupload下载文件,为什么只能用绝对路径???
String ps=sqlRst.getString( "T_pname ");//获得文件名
String str= "D:/Tomcat 5.5/webapps/ROOT/abc/upload/ "+ps;
String Path= new String(str.getBytes( "GBK "), "UTF-8 ");
java.io.File dir=new java.io.File(Path);
SmartUpload su = new SmartUpload();
su.initialize(pageContext);
su.setContentDisposition(null);
su.downloadFile(Path, "application/x-msdownload ");
可以下载,为什么我用
String str= "/upload/ "+ps;
却不能下载呢,这样别的机器就不能访问本机来下载了啊,请高手指点...
------解决方案--------------------你用request.getSession().getServletContext().getRealPath( "/upload ")来获得文件夹路径试试.