Closed suhaotian closed 8 years ago
{maxUploads:1}
?
@enumag It didn't work:
last two don't upload ...
Can you post your code
yes,
var cert_uploader_ss = new ss.SimpleUpload({
button: query('cert_upload_btn'),
url: '/v.php/Home/Index/getApi.html',
debug: true,
multipart: true,
multiple: true,
maxUploads: 1,
// queue: false,
name: 'cert',
allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
accept: 'image/*',
autoSubmit: false,
responseType: 'html',
onChange: function(filename, extension, uploadBtn, fileSize, file) {
console.log(filename)
var isEqual = cert_dom_wrap.querySelector('#_' + (filename + fileSize).replace('.', '_'))
if(!!isEqual) {
alert('您已上传该图片!')
cert_uploader_ss.clearQueue()
return false
}
maxI++
if (maxI == 5) {
cert_btn.style.display = 'none'
}
// cert_btn.style.display = 'none'
if(maxI > 5) {
return false
}
var self = this;
wrap_img = document.createElement('div')
wrap_img.setAttribute('id', ('_' + filename + fileSize).replace('.', '_'))
cert_img = document.createElement('img')
wrap_img.classList.add('uploader_file')
cert_overlay = document.createElement('div')
cert_overlay.className = 'uploader_file_overlay'
cert_overlay.style.display = 'block'
cert_overlay.textContent = '正在上传...'
wrap_img.appendChild(cert_img)
wrap_img.appendChild(cert_overlay)
cert_dom_wrap.appendChild(wrap_img)
},
onProgress: function(n){
// console.log(n) // 进度条
},
onSubmit: function( filename, extension, uploadBtn, fileSize) {
var self = this;
self.setData({
name: 'cert',
hash: 'custom_hash',
reType: 'html'
})
},
How are you submitting each upload since you have autoSubmit: false
@LPology :astonished: thank you !!
One other tip: if you only want to remove one file inside of onChange()
here:
if(!!isEqual) {
alert('您已上传该图片!')
cert_uploader_ss.clearQueue()
return false
}
You may want to use removeCurrent()
instead of clearQueue()
. Using clearQueue()
clears out all selected fies, whereas removeCurrent()
only removes the current file.
@LPology :smile: thank you !!
pls help me :cry: