JQuery自动上传
解决时间 2021-04-13 23:48
- 提问者网友:寂寞梧桐
- 2021-04-13 15:23
jQuery(document).ready(function ($) var i = 1,$example_dropzone_filetable = $("#example-dropzone-filetable"),example_dropzone = $("#advancedDropzone").dropzone({url: '../FileUpload/Upload',addedfile: function (file) {if (i == 1) {$example_dropzone_filetable.find('tbody').html('');}var size = parseInt(file.size / 1024, 10);size = size < 1024 ? (size + " KB") : (parseInt(size / 1024, 10) + " MB");var $el = $('
\'+ (i++) + ' | \'+ file.name + ' | \ | \' + size + ' | \'+file.url+' | \
Uploading... | \
');$example_dropzone_filetable.find('tbody').append($el);file.fileEntryTd = $el;file.progressBar = $el.find('.progress-bar');},uploadprogress: function (file, progress, bytesSent) {
file.progressBar.width(progress + '%');},success: function (file) {file.fileEntryTd.find('td:last').html('上传成功');file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-success');},error: function (file) {file.fileEntryTd.find('td:last').html('失败');file.progressBar.removeClass('progress-bar-warning').addClass('progress-bar-red');}});$("#advancedDropzone").css({ minHeight: 200});});
怎么接受返回值?
最佳答案
- 五星知识达人网友:荒野風
- 2021-04-13 16:32
success: function (file) 这里是ajax调用成功后的方法,参数file就是从server侧取回的返回值
全部回答
- 1楼网友:第幾種人
- 2021-04-13 17:22
这个应该是没法解决的,你找到文件的时候调用的是windows系统本身的组件,你要选中然后就能自动上传的话,需要去调用你系统js的上传方法,除非你去改造windows组件,或者选择文件的时候不调用系统组件,而是自己重新去写页面跟方法,不过从成本、时间上来说,得不偿失!
我要举报
大家都在看
推荐资讯