H5移动前端图片批量压缩上传

留言总数 35 条 · 顶层留言 28 条 · 第 2 / 2 页 · 每页 15 条

返回插件详情
Gary
安卓只能单张图片
郑州-前端-小白菜
亲,安卓只能上传一张图片吗?
小诗仙小白
@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咄咄o

这是啥

犯二青年的Le趣
依旧没明白怎么用
Mr_豪大哥哥
有没有php后台写的
Mr_豪大哥哥
有没有php后台写的
郑州-前端-小白菜
亲,你的问题解决了吗?求指教!!!
tangli
安卓手机不能多图上传,ios的可以
??柒柒??
限制上传数目不对
陌路行同
这个上传后的图片是压缩过的吗
Freed
用node写的后台,可惜用不了,楼主要是能给个php后台就好了
dombom
后台可以自己改吗?
my heart
图片地址是怎么上传上去的,没有node.js也有一串图片地址代码
HuHuaChuan
有返回图片地址就好了
波光
响应式部门好腻害
简~单~
这个不错啊
...
确实挺好用的
驭势

你们可以直接运行吗?怎么调试的,为甚么我的不能运行呢?