67,513
社区成员
发帖
与我相关
我的任务
分享
public String uploadImage(InputStream Images){
WebContext webContext=WebContextFactory.get();
String saveurl=webContext.getHttpServletRequest().getSession().getServletContext().getRealPath("/image/goods_pic");
File file=new File(saveurl+"/"+"wo");
try {
int available=Images.available();
byte[] b=new byte[available];
FileOutputStream foutput=new FileOutputStream(file);
Images.read(b);
foutput.write(b);
foutput.flush();
foutput.close();
Images.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "图片上传成功!";
}