在系统需要上传图片,但是不要把图片放到web路径下,这个时候就在硬盘上的另外地方
设置一个图片文件夹,
然后再读取硬盘上的图片,然后显示到JSP页面上
代码如下:
String path=("path");
File picFile = new File(path);
if(!()){
String uploadDir=(().getServletContext(), "/");
path=uploadDir+"//crmres//images//" ;
picFile = new File(path);
}
("image/jpeg; charset=GBK");
//("Content-Disposition", "attachment; filename="+new String("".getBytes("GBK"),"ISO8859_1"));
ServletOutputStream outputStream = ();
FileInputStream inputStream = new FileInputStream(picFile);
byte[] buffer = new byte[1024];
int i = -1;
while ((i = (buffer)) != -1) {
(buffer, 0, i);
}
();
();
();
outputStream = null;
return null;