webuploader + springmvc上传
2016-01-24 15:45
621 查看
摘要: webuploader + springmvc上传
首先去官网下载:http://fex.baidu.com/webuploader/download.html
前台:
放到项目里面,修改upload.js中的server:'up';
修改webuploader.js中的sendAsBinary: false
sendAsBinary {Object} [可选] [默认值:false] 是否已二进制的流的方式发送文件,这样整个上传内容php://input都为文件内容, 其他参数在$_GET数组中。
可以修改一下提示和上传文件的类型以及大小:
uploader.onError = function( code ) {
if(code=="Q_EXCEED_NUM_LIMIT"){
alert("超出最大张数!");
}else if(code=="F_DUPLICATE"){
alert("文件重复!");
}else if(code=="Q_TYPE_DENIED"){
alert("不允许上传的类型!");
}else{
alert( 'Eroor: ' + code );
}
};
后台:
修改springmvc的配置文件
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</beans:bean>
Controller中:
@RequestMapping(value = ("/up"), method = RequestMethod.POST)
public void upload(@RequestParam("file") MultipartFile file,HttpServletRequest request,HttpServletResponse response) {
try {
//得到图片去保存吧!
UpfileInfo up = super.upload(file, request,tid);
upfileService.add(up);
} catch (Exception e) {
e.printStackTrace();
}
}
首先去官网下载:http://fex.baidu.com/webuploader/download.html
前台:
放到项目里面,修改upload.js中的server:'up';
修改webuploader.js中的sendAsBinary: false
sendAsBinary {Object} [可选] [默认值:false] 是否已二进制的流的方式发送文件,这样整个上传内容php://input都为文件内容, 其他参数在$_GET数组中。
可以修改一下提示和上传文件的类型以及大小:
uploader.onError = function( code ) {
if(code=="Q_EXCEED_NUM_LIMIT"){
alert("超出最大张数!");
}else if(code=="F_DUPLICATE"){
alert("文件重复!");
}else if(code=="Q_TYPE_DENIED"){
alert("不允许上传的类型!");
}else{
alert( 'Eroor: ' + code );
}
};
后台:
修改springmvc的配置文件
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
</beans:bean>
Controller中:
@RequestMapping(value = ("/up"), method = RequestMethod.POST)
public void upload(@RequestParam("file") MultipartFile file,HttpServletRequest request,HttpServletResponse response) {
try {
//得到图片去保存吧!
UpfileInfo up = super.upload(file, request,tid);
upfileService.add(up);
} catch (Exception e) {
e.printStackTrace();
}
}
相关文章推荐
- PHP+jQuery+Ajax实现多图片上传效果
- LINUX6不能启动,bringing up interface eth0:
- Direct3D基础
- dnf第七章waiguaⅢ∨dnf第七章好感度【=dnf第七章免费外挂
- How to do the trade after new updates?
- instances) and similar IP handles (that may additionally report that one particular person is filling out the prospect kind vari
- problems that may cause a
- cheap Seattle Seahawks jersey b2bjersey.com 0o
- Louis Vuitton and Annie Leibovitz
- the startup type and services status of services' properties
- LV collaboration with Rei Kawakubo opened shop in Tokyo
- Christian louboutin voice
- How to Perfectly Uninstall Spybot – Search & Destroy
- 背完这446句,你的口语绝对不成问题了
- new moncler
- Nike AIR Force
- They may come plain or be tiffany jewelry wholesale
- Most gemstones can be Tiffany jewelry
- The ceramic copy will be hollow and Tiffany jewelry
- You can find tiffany jewelry