Gary0
2016/11/29 17:11:08
安卓只能单张图片
郑州-前端-小白菜0
2016/12/1 14:12:13
回复
小诗仙小白0
2016/11/18 19:11:12
@RequestMapping(value = "upload", method = RequestMethod.POST) public String upload(HttpServletRequest request, HttpServletResponse response) throws Exception {
String localPath = "/static/upload";
String uploadPath = request.getRealPath(localPath);
File dir = new File(uploadPath);
if (!dir.exists()) dir.mkdirs();
String fileName = uploadPath + "/" + SequenceUtil.uuid2() + ".jpg";
if (request instanceof MultipartRequest) {
MultiValueMap < String,
MultipartFile > map = ((MultipartRequest) request).getMultiFileMap();
LinkedList < CommonsMultipartFile > imageList = (LinkedList) map.get("imagefile");
if (imageList != null && imageList.size() > 0) {
CommonsMultipartFile file = imageList.get(0);
if (!file.isEmpty()) {
try {
BASE64Encoder encoder = new BASE64Encoder();
BASE64Decoder decoder = new BASE64Decoder(); // 通过base64来转化图片
String data = encoder.encode(file.getBytes());
byte[] bytes = decoder.decodeBuffer(data);
for (int i = 0; i < bytes.length; ++i) {
if (bytes[i] < 0) { // 调整异常数据
bytes[i] += 256;
}
} // 生成jpeg图片
OutputStream out = new FileOutputStream(fileName);
out.write(bytes);
out.flush();
out.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
}
return null;
}
o咄咄o0
2016/12/21 17:12:14
回复
犯二青年的Le趣0
2016/11/14 15:11:55
Mr_豪大哥哥0
2016/11/14 14:11:06
Mr_豪大哥哥0
2016/10/28 17:10:25
有没有php后台写的
郑州-前端-小白菜0
2016/12/1 15:12:43
回复
tangli0
2016/8/30 19:08:50
??柒柒??0
2016/8/23 17:08:22
用node写的后台,可惜用不了,楼主要是能给个php后台就好了
dombom0
2016/9/26 10:09:40
回复
my heart0
2016/7/25 14:07:07
图片地址是怎么上传上去的,没有node.js也有一串图片地址代码
回复
HuHuaChuan0
2016/7/21 17:07:52
讨论这个项目(35)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约