就是我现在遇到一个难题,客户端是第三方的SDK插件配合我的java,定时产生一定的图片,
存放在客户端本地的路径文件夹,没有传到我这边的服务器上,我尝试过用js,通过浏览器,
来获取,但是不行,只有低版本的IE有个不安全的插件可以做到,但是高版本的IE又不兼容了,
火狐、谷歌那些浏览器暂时找不到类似的插件,我是想,有没有办法让代码去扫描客户端的文件夹获取文件?求助大神
即便是有,出于安全上的考虑,估计也不允许
public CommodityAddDto addCommodity(@RequestParam("photo") CommonsMultipartFile photo, String name, String type,
String content, HttpSession session) throws Exception {
CommodityAddDto commodityAddDto = new CommodityAddDto();
String oldFileName = photo.getOriginalFilename();
String extendName = oldFileName.substring(oldFileName.lastIndexOf("."));
String newFileName = UUID.randomUUID().toString() + extendName;
String realyPath = session.getServletContext().getRealPath("/upload");
System.out.println("-------------" + realyPath);
File saveDir = new File(realyPath);
if (!saveDir.exists()) {
saveDir.mkdir();
}
File saveFile = new File(saveDir, newFileName);
photo.transferTo(saveFile);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date date = new Date();
String datatime = format.format(date);
Commodity commodity = new Commodity();
Type type2 = iTypeServices.queryByType(type);
commodity.setName(name);
commodity.setType(type2);
commodity.setPhoto(newFileName);
commodity.setContent(content);
commodity.setDatatime(datatime);
boolean result = iCommodityServices.insert(commodity);
String mess = null;
if (result == true) {
mess = "添加成功";
} else {
mess = "添加失败";
}
System.out.println(mess);
commodityAddDto.setResult(result);
commodityAddDto.setMess(mess);
return commodityAddDto;
}
之前做人像的时候,本机测试的时候,是直接传文件路径,远程的时候,本地往服务器传,直接把图片转成base64,ajax传递。要反向,你从服务器根据路径取客户端图片,感觉应该不行吧,有点像骇客了,
浏览器协议禁止了,我之前用php也遇到过类似情况,在IE6下面是可以的