webupload 如何在上传过程中 判断不符合要求 禁止上传

uploader.on('fileQueued', function (file) {
            console.log(file);

            WebUploader.Runtime.Html5.Util.parseMeta(file.source, function (error, ret) {
                var lat = ret.exif.get(0x0002);
                var lon = ret.exif.get(0x0004);

                if (lat !== undefined || lon !== undefined) {
                    console.log(lat);
                }else {
                    //alert("图片没有gps信息");
                    uploader.onError("图片没有gps信息");
                    return false;
                    //$( '#'+file.id ).find('p.state').text('上传出错');
                }
            });

        });

为什么弹出后 还能上传 !

  uploader.on('beforeFileQueued', function (file) {


            WebUploader.Runtime.Html5.Util.parseMeta(file.source, function (error, ret) {
                var  lat = ret.exif.get(0x0002);
                var  lon = ret.exif.get(0x0004);

                if (lat !== undefined || lon !== undefined) {
                    console.log(lat);
                } else {
                    //uploader.onError("图片没有gps信息");
                    return false;
                }
            });

        });

这么写还是不行

阅读 4.3k
2 个回答

多看看API文档啊 http://fex.baidu.com/webuploa...

fileQueued 是当文件被加入队列以后触发。
都加入到队列了,返回false有毛用

**用beforeFileQueued
是当文件被加入队列之前触发,此事件的handler返回值为false,则此文件不会被添加进入队列。**

fileQueued 事件是文件加入队列后触发的,应该用beforeFileQueued

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题