当前位置: 移动技术网 > IT编程>开发语言>JavaScript > 解决layui上传文件提示上传异常,实际文件已经上传成功的问题

解决layui上传文件提示上传异常,实际文件已经上传成功的问题

2018年09月26日  | 移动技术网IT编程  | 我要评论

layui上传文件提示上传异常,实际文件已经上传成功

原因:上传回调的方法接收的参数应该是json格式的,之前返回的是string,所以一直走异常的方法

@responsebody
@requestmapping("/web/upload")
public jsonobject uploadsourcedata(@requestparam(value="file") multipartfile file ){
string filepath = “”;
string filename = filepath+system.currenttimemillis()+"_"+file.getoriginalfilename(); //上传后的文件名  原始文件名加上时间戳
fileoutputstream out;
jsonobject resobj = new jsonobject();
resobj.put("msg", "ok");
try {
out = new fileoutputstream(new file(filename));
ioutils.copy(file.getinputstream(), out);
out.close();
} catch (exception e) {
// todo auto-generated catch block
resobj.put("msg", "error");
e.printstacktrace();
}
return resobj;
}

以上这篇解决layui上传文件提示上传异常,实际文件已经上传成功的问题就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持移动技术网。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网