Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
502 views
in Technique[技术] by (71.8m points)

求教:当使用webuploader上传图片时,服务器响应数据内容格式是什么

我前端使用百度的webUploader上传插件来上传图片,而后端使用Thinkphp来接收文件数据,但如果我后端接收文件出错时,该如何返回数据通知前端调用uploadError事件回调方法执行呢?

我看了官方文档,没有说明。。。。我试了很多数据格式,但前端依然执行uploadSuccess事件方法。。。特此求助下,成功是该返回什么数据格式,失败是该返回什么数据格式?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

说个方式你参考下:
服务端返回json。返回的json里有个状态标识上传是否成功。前端应在uploadSuccess回调里面判断服务端上传是否成功。

而uploadError这个事件,应该是服务端状态码错误时才会触发,比如说服务端返回500


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...