小程序图片上传整合springmvc
2017-09-13 11:13
267 查看
前端:
legenIndexViewTap: function() {
wx.chooseImage({
count: 1,
sizeType: ['orignal', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilePaths = res.tempFilePaths[0];
wx.uploadFile({
url: url,
filePath: tempFilePaths,
name: 'imageFile',
formData: {
userId: value1,
filePath:tempFilePaths//后台参数filePath
},
success: function (res) {
var data = res.data
console.log(data)
},
fail:function(){
console.log("fail");
}
});
console.log(tempFilePaths);
},
fail: function () {
console.log("fail");
},
complete: function () {
console.log("complete");
}
})
//wx.navigateTo({
// url: '../doctor/doctor_zone'
// })
}
后台:
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseBody
public Object uploadDiagFile(@RequestParam("imageFile") MultipartFile file, String filePath,String userId) throws IOException {
commonService.uploadWxImge(file.getInputStream(), filePath, userId, "user/diag");
return "success";
}
public void uploadWxImge(InputStream imageFile,String filePath, String userId, String type){
ArrayList<FileInfo> files = new ArrayList<FileInfo>();
ImageInfo file = new ImageInfo();
String fileName = getImgName(filePath);
String ext = filePath.substring(filePath.lastIndexOf(".") + 1);
file.setName(fileName);
file.setExt(ext);
file.setType(type);
file.setRelId(userId);
file.setStream(imageFile);
files.add(file);
if(!Utility.isNullOrEmpty(imageFile)) {
// 图片上传
RemoteImageWithThumbHandler imageThread = new RemoteImageWithThumbHandler(files);
imageThread.start();
}
}
其实下面就是一般图片上传处理了。
legenIndexViewTap: function() {
wx.chooseImage({
count: 1,
sizeType: ['orignal', 'compressed'],
sourceType: ['album', 'camera'],
success: function (res) {
var tempFilePaths = res.tempFilePaths[0];
wx.uploadFile({
url: url,
filePath: tempFilePaths,
name: 'imageFile',
formData: {
userId: value1,
filePath:tempFilePaths//后台参数filePath
},
success: function (res) {
var data = res.data
console.log(data)
},
fail:function(){
console.log("fail");
}
});
console.log(tempFilePaths);
},
fail: function () {
console.log("fail");
},
complete: function () {
console.log("complete");
}
})
//wx.navigateTo({
// url: '../doctor/doctor_zone'
// })
}
后台:
@RequestMapping(value = "", method = RequestMethod.POST)
@ResponseBody
public Object uploadDiagFile(@RequestParam("imageFile") MultipartFile file, String filePath,String userId) throws IOException {
commonService.uploadWxImge(file.getInputStream(), filePath, userId, "user/diag");
return "success";
}
public void uploadWxImge(InputStream imageFile,String filePath, String userId, String type){
ArrayList<FileInfo> files = new ArrayList<FileInfo>();
ImageInfo file = new ImageInfo();
String fileName = getImgName(filePath);
String ext = filePath.substring(filePath.lastIndexOf(".") + 1);
file.setName(fileName);
file.setExt(ext);
file.setType(type);
file.setRelId(userId);
file.setStream(imageFile);
files.add(file);
if(!Utility.isNullOrEmpty(imageFile)) {
// 图片上传
RemoteImageWithThumbHandler imageThread = new RemoteImageWithThumbHandler(files);
imageThread.start();
}
}
其实下面就是一般图片上传处理了。
相关文章推荐
- 小程序图片上传整合springmvc
- SpringMVC:学习笔记(10)——整合Ckeditor且实现图片上传
- 微信小程序上传图片到服务器(java后台以及使用springmvc)
- UMeditor与SpringMVC的整合和上传图片使用
- 【SpringMVC整合MyBatis】springmvc上传图片
- bootstrap fileinput 组件整合SpringMVC上传图片到本地磁盘
- bootstrap fileinput 组件整合SpringMVC上传图片到本地磁盘
- bootstrap fileinput组件整合Springmvc上传图片到本地磁盘
- SpringMVC整合KindEditor,实现图片上传、预览、删除
- ASP_一般处理程序_图片上传
- 微信小程序开发之图片上传+Java服务端接收
- Word图片上传控件整合文档(Z-Blog)-Xproer.WordPaster
- SpringMVC上传图片总结(1)-Web Uploader--常规方法进行图片上传,使用了MultipartFile、MultipartHttpServletRequest
- 在使用springmvc上传图片 The current request is not a multipart request 错误
- Word图片上传控件整合文档(CKEditor3.x)-Xproer.WordPaster
- Ckeditor结合springmvc的使用、配置、上传图片、分页
- springmvc图片上传(夹杂普通字段一次性处理)
- SpringMVC中使用ajaxfileupload异步上传图片文件视频
- springmvc图片上传
- 微信小程序-从相册获取图片,视频 使用相机拍照,录像上传+服务器(nodejs版)接收