点击三次input按钮,前两次不选择任何文件,第三次选择一个文件,结果页面上出现了3个文件,也就是上传了3个文件

我点击input,不选择任何文件,然后取消文件选择器的窗口,然后第二次次点击input,同样不选择文件然后关闭,第三次点击input选择一个文件,结果页面上出现了三个个文件,且三个文件相同

就是说我点击三次input,前两次不选择任何文件,第三次选择一个文件上传,结果是上传了3个文件。

这是什么原因导致的,我的文件上传窗口只显示一个文件,上传窗口里面的数据和input里面的文件数是一致的

代码如下:

{% trans "Upload"%}

{% trans "Upload folder"%}

为什么点击三次input按钮,前两次不选择任何文件,第三次选择一个文件,结果页面上出现了3个文件,也就是上传了3个文件

function xx() {

console.log(cur_path);

var popup = $('#upload-file-dialog').addClass('fixed-upload-file-dialog');;

var popup_height = '200px';

popup.css({'height': popup_height}).data('height', popup_height);

var fu_status = $('.status', popup),

total_progress = $('.total-progress', popup),

cancel_all_btn = $('.fileupload-buttonbar .cancel', popup),

close_icon = $('.close', popup),

saving_tip = $('.saving-tip', popup);

var fu_status_ = {

'uploading': "{% trans "File Uploading..." %}",

'complete': "{% trans "File Upload complete" %}",

'canceled': "{% trans "File Upload canceled" %}",

'failed': "{% trans "File Upload failed" %}"

};

popup.fileupload({

formData: {'parent_dir': cur_path},

fileInput: $('#upload-file input'),

paramName: 'file',

// customize it for 'done'

getFilesFromResponse: function (data) {

if (data.result) {

return data.result;

}

},

autoUpload:true,

{% if max_upload_file_size %}

maxFileSize: {{ max_upload_file_size }}, // in bytes

{% endif %}

maxNumberOfFiles: 500,

sequentialUploads: true

})

.bind('fileuploadadd', function(e, data) {

//var files = e.target.files; // FileList

//for (var i = 0, f; f = files[i]; ++i) {

//console.log(files[i].webkitRelativePath);

// $("#upload-file").data("dir",files[i].webkitRelativePath)

//}

//console.log(e);

popup.removeClass('hide');

cancel_all_btn.removeClass('hide');

close_icon.addClass('hide');

})

.bind('fileuploadstart', function() {

fu_status.html(fu_status_.uploading);

})

.bind('fileuploadsubmit', function(e, data) {

if (data.files.length == 0) {

return false;

}

var file = data.files[0];

var xx = data.files[0].webkitRelativePath;

//var yy = typeof(xx);

console.log(file);

// get url(token) for every file

//if(file.error){

// console.log(file.error);

//}

//console.log(cur_path);

if (!file.error) {

$.ajax({

url: '{% url 'get_file_op_url' repo.id %}',

cache: false,

data: {

'op_type': 'upload',

'path': cur_path,

},

dataType: 'json',

success: function(ret) {

data.url = ret['url'];

data.jqXHR = popup.fileupload('send', data);

},

error: function() {

file.error = "{% trans "Failed to get upload url" %}";

}

});

return false;

}

})

.bind('fileuploadprogressall', function (e, data) {

total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ').removeClass('hide');

//console.log(parseInt(data.loaded / data.total * 100, 10))

if (data.loaded > 0 && data.loaded == data.total) {

saving_tip.show();

}

})

.bind('fileuploadstop', function() {

//setTimeout(function() { location.reload(true); }, 1000);

})

// after tpl has rendered

.bind('fileuploadcompleted', function() { // 'done'

if ($('.files .cancel', popup).length == 0) {

saving_tip.hide();

total_progress.addClass('hide');

fu_status.html(fu_status_.complete);

}

})

.bind('fileuploadfailed', function(e, data) { // 'fail'

if ($('.files .cancel', popup).length == 0) {

cancel_all_btn.addClass('hide');

close_icon.removeClass('hide');

total_progress.addClass('hide');

saving_tip.hide();

if (data.errorThrown == 'abort') { // 'cancel'

fu_status.html(fu_status_.canceled);

} else { // 'error'

fu_status.html(fu_status_.failed);

}

}

});

// Enable iframe cross-domain access via redirect option:

popup.fileupload(

'option',

'redirect',

window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, '{{ MEDIA_URL }}cors/result.html?%s')

);

};

function yy() {

console.log(cur_path);

var popup = $('#upload-file-dialog').addClass('fixed-upload-file-dialog');;

var popup_height = '200px';

popup.css({'height': popup_height}).data('height', popup_height);

var fu_status = $('.status', popup),

total_progress = $('.total-progress', popup),

cancel_all_btn = $('.fileupload-buttonbar .cancel', popup),

close_icon = $('.close', popup),

saving_tip = $('.saving-tip', popup);

var fu_status_ = {

'uploading': "{% trans "File Uploading..." %}",

'complete': "{% trans "File Upload complete" %}",

'canceled': "{% trans "File Upload canceled" %}",

'failed': "{% trans "File Upload failed" %}"

};

popup.fileupload({

//formData: {'parent_dir': cur_path},

fileInput: $('#upload-file2 input'),

paramName: 'file',

// customize it for 'done'

getFilesFromResponse: function (data) {

if (data.result) {

return data.result;

}

},

autoUpload:true,

{% if max_upload_file_size %}

maxFileSize: {{ max_upload_file_size }}, // in bytes

{% endif %}

maxNumberOfFiles: 500,

sequentialUploads: true

})

.bind('fileuploadadd', function(e, data) {

var files = e.target.files; // FileList

//for (var i = 0, f; f = files[i]; ++i) {

//console.log(files[i].webkitRelativePath);

// $("#upload-file").data("dir",files[i].webkitRelativePath)

//}

console.log(files[0]);

popup.removeClass('hide');

cancel_all_btn.removeClass('hide');

close_icon.addClass('hide');

})

.bind('fileuploadstart', function() {

fu_status.html(fu_status_.uploading);

})

.bind('fileuploadsubmit', function(e, data) {

if (data.files.length == 0) {

return false;

}

var file = data.files[0];

var uu = data.files[0].webkitRelativePath;

//var yy = typeof(uu);

console.log(file);

// get url(token) for every file

//if(file.error){

// console.log(file.error);

//}

if (!file.error) {

$.ajax({

url: '{% url 'get_file_op_url' repo.id %}',

cache: false,

data: {

'op_type': 'upload',

'path': cur_path,

'dir-structure':uu,

},

dataType: 'json',

success: function(ret) {

data.url = ret['url'];

data.formData = {parent_dir:cur_path+ret['path']}

//console.log(ret['path']);

data.jqXHR = popup.fileupload('send', data);

},

error: function() {

file.error = "{% trans "Failed to get upload url" %}";

}

});

return false;

}

})

.bind('fileuploadprogressall', function (e, data) {

total_progress.html(parseInt(data.loaded / data.total * 100, 10) + '% ').removeClass('hide');

//console.log(parseInt(data.loaded / data.total * 100, 10))

if (data.loaded > 0 && data.loaded == data.total) {

saving_tip.show();

}

})

.bind('fileuploadstop', function() {

//setTimeout(function() { location.reload(true); }, 5000);

})

// after tpl has rendered

.bind('fileuploadcompleted', function() { // 'done'

if ($('.files .cancel', popup).length == 0) {

saving_tip.hide();

total_progress.addClass('hide');

fu_status.html(fu_status_.complete);

}

})

.bind('fileuploadfailed', function(e, data) { // 'fail'

if ($('.files .cancel', popup).length == 0) {

cancel_all_btn.addClass('hide');

close_icon.removeClass('hide');

total_progress.addClass('hide');

saving_tip.hide();

if (data.errorThrown == 'abort') { // 'cancel'

fu_status.html(fu_status_.canceled);

} else { // 'error'

fu_status.html(fu_status_.failed);

}

}

});

// Enable iframe cross-domain access via redirect option:

popup.fileupload(

'option',

'redirect',

window.location.href.replace(/\/repo\/[-a-z0-9]{36}\/.*/, '{{ MEDIA_URL }}cors/result.html?%s')

);

};

$('#upload-file').click(xx);

$('#upload-file2').click(yy);

// fold/unfold the dialog

$('#upload-file-dialog .fold-switch').click(function() {

var popup = $('#upload-file-dialog');

var full_ht = parseInt(popup.data('height'));

var main_con = $('.fileupload-buttonbar, .table', popup);

if (popup.height() == full_ht) {

popup.height($('.hd', popup).outerHeight(true));

main_con.addClass('hide');

} else {

popup.height(full_ht);

main_con.removeClass('hide');

}

});

$('#upload-file-dialog .close').click(function() {

$('#upload-file-dialog').addClass('hide');

$('#upload-file-dialog .files').empty();

});

window.locale = {

"fileupload": {

"errors": {

"maxFileSize": "{% trans "File is too big" %}",

"minFileSize": "{% trans "File is too small" %}",

"acceptFileTypes": "{% trans "Filetype not allowed" %}",

"maxNumberOfFiles": "{% trans "Max number of files exceeded" %}",

"uploadedBytes": "{% trans "Uploaded bytes exceed file size" %}",

"emptyResult": "{% trans "Empty file upload result" %}"

},

"error": "{% trans "Error" %}",

"uploaded": "{% trans "uploaded" %}",

"canceled": "{% trans "canceled" %}",

"start": "{% trans "Start" %}",

"cancel": "{% trans "Cancel" %}",

"destroy": "{% trans "Delete" %}"

}

};

$(function(){

var agent = navigator.userAgent.toLowerCase();

if(agent.indexOf(' applewebkit/') == -1){

$("#upload-file2").hide()

}

});

jquery 文件上传 触发两次_点击三次input按钮,前两次不选择任何文件,第三次选择一个文件,结果上传了3个文件,即发生了三次请求...相关推荐

  1. mysql删除字段前两位_删除MySQL中所有字段的前两个字符?

    要删除所有字段的前两个字符,您需要使用SUBSTRING()MySQL中的function.语法如下-UPDATE yourTableName SET yourColumnName=SUBSTRING ...

  2. SQL练习题_ 查询每个部门工资最高的前两名的姓名和部门名称【多测师_何sir】

    查询每个部门工资最高的前两名的姓名和部门名称 第一种解决方案: 第二种解决方案: SQL练习题: 假设一个部门有4个人,A,B,C,D A的工资=10000 B的工资=9000 C的工资=8000 D ...

  3. 抓交通肇事犯。一辆卡车违反交通规则,撞人后逃跑。现场有三人目击事件,但都没有记住车号,只记下车号的一些特征。甲说:牌照的前两位数字是相同的;乙说:牌照的后两位数字是相同的,但与前两位不同; 丙是数学家

    抓交通肇事犯.一辆卡车违反交通规则,撞人后逃跑.现场有三人目击事件,但都没有记住车号,只记下车号的一些特征.甲说:牌照的前两位数字是相同的:乙说:牌照的后两位数字是相同的,但与前两位不同: 丙是数学家 ...

  4. mysql 查询前两名_Mysql:查询每门课程成绩的前两名

    一张成绩表,查询每门课程的前两名,咋一看无从下手,其实可以理解为表自连接 . 建表语句: CREATE TABLE `Department` ( `Id` int(11) NOT NULL DEFAU ...

  5. Java程序的类体两部分_一般Java程序的类体由两部分组成:一部分是____,另一部分是____。...

    [单选题]在PowerPoint2010幻灯片中,直接插入*.swf格式Flash动画文件的方法是 [填空题]A企业存在2个辅助生产车间,供电车间和供水车间, 5 月,供电车间共发生耗费 6460 元 ...

  6. Office文档上传后实时转换为PDF格式_图片文件上传后实时裁剪_实现在线预览Office文档

    Office文档上传后实时转换为PDF格式_图片文件上传后实时裁剪 前置条件 安装LibreOffice 安装OpenOffice 安装Unoconv 安装ImageMagick.x86_64 安装G ...

  7. dropzonejs vue 使用_如何在Dropzone上手动触发上传文件事件

    我将Dropzonejs很好地集成到了我的前端(VueJS)中.如何在Dropzone上手动触发上传文件事件 我有验收测试Dropzone使用Webdriver/Codeception的问题.底线是W ...

  8. 微信里文件小程序导不出来_懒得打开电脑传文件?这四类小程序把这事解决了-小程序视频怎么发在电脑上...

    在<小程序说·能力百科全书>前两期中,我们说到了小程序的"蓝牙能力".弱网环境下,它是篮球场上力挽狂澜的"第六人":出行场景中,它还能化身你的&qu ...

  9. swiper 上滑触发_四种方式快速实现上滑触底加载效果

    在智能小程序的开发过程中,上拉加载是一种十分常见的加载效果,最近也收到了一些开发者在开发上拉加载时遇到的问题,今天的内容就为您介绍一下如果想实现下述效果的上拉加载,我们需要如何去做. 以下是为大家总结 ...

最新文章

  1. Kostya Keygen#2分析
  2. 更换yum的源为阿里云或者网易
  3. hadoop常用命令之hdfs
  4. 应用程序框架实战二十一:DDD分层架构之仓储(介绍篇)
  5. qt 中转化图片格式与大小的方法
  6. PE文件结构详解(四)PE导入表
  7. as it exceeds the max of 500KB._我的英雄学院The “Ultra” Stage角色介绍第三弹!
  8. 持续集成部署Jenkins工作笔记0010---创建工程并配置源码管理
  9. firefox css3 transform样式 位置偏移问题解决
  10. 战德臣计算机导论第5讲,地方高校“计算机导论”算法思维培养的教学设计
  11. PostMan是一款不可多得的发包工具
  12. linux resin目录,Linux下resin的安装以及配置:
  13. 用PS给证件照换底色
  14. 中国电信官方提醒:7类短信诈骗须警惕
  15. 解决mysql主从 The slave IO thread stops because the master has @@GLOBAL.GTID_MODE OFF and this server
  16. 控制 input 输入框不能输入中文,即不能在输入框中使用输入法
  17. 茶文化网站html模板,茶文化网页模板图片
  18. 发生系统错误1067
  19. 杂谈:中华英才裁员事件
  20. js jq 图片上传功能

热门文章

  1. matlab 三维点 边界曲面,不用matlab如何从散点数据绘制极坐标三维曲面图?
  2. zypper 删除mysql_如何在 Linux 上安装/卸载一个文件中列出的软件包?
  3. 转换图片保持画质_图片格式怎么相互转换,如何转换jpg、 bmp、png格式
  4. iOS内存管理机制解析
  5. 常用的linux文件权限
  6. 《Python从小白到大牛》第5章 Python编码规范
  7. STL学习系列五:Queue容器
  8. phpcms v9 打开网站特别慢 增加数据库缓存方法
  9. Deploy Oracle 10.2.0.5 DataGuard on Red Hat Enterprise Linux 6.4
  10. java对菜单项的监听_我是新手,请问大神java菜单项和下拉列表添加监听和监听方法???有变量和方法就行了...