upload bug修复

This commit is contained in:
Joe 2016-12-28 13:32:25 +08:00
parent 3dc9155a1f
commit 1ce357fb20
1 changed files with 21 additions and 13 deletions

View File

@ -4,7 +4,12 @@
var pic_num = 0,pic_maxnum = 5; // 用来动态生成span,upfile的id,一次上传图片数量接口
function addAttachmentToList()
{
if (findAttachment(event.srcElement.value)) return; //如果此文档已在图片列表中则不再添加
if (findAttachment(event.srcElement.value)){
var o = G('pics').getElementsByTagName('input');
var len = o.length-1;
G('pics').removeChild(o[len]);
return;
}; //如果此文档已在图片列表中则不再添加
if (extractFileName(event.srcElement.value)){
// 动态创建图片信息栏并添加到图片列表中
var span = document.createElement('span');
@ -28,9 +33,10 @@ function addAttachmentToList()
function selectAttachment()
{
// 先清除无效动态生成的多余upfile
cleanInvalidUpfile();
if(pic_num < pic_maxnum) {//图片数量控制接口
if(pic_num < pic_maxnum ) {//图片数量控制
var upfile = '<input type="file" style="display:none" onchange="addAttachmentToList();" id="_upfile'+pic_num+'">';// 动态创建上传控件并与span对应
G('pics').insertAdjacentHTML('beforeEnd', upfile);
G('_upfile'+pic_num).click();
@ -78,13 +84,15 @@ function delAttachment(id)
function cleanInvalidUpfile()
{
var o = document.body.getElementsByTagName('input');
for(var i=o.length-1;i>=0;i--)
var o = G('pics').getElementsByTagName('input');
var len = o.length-1;
for(var i=o.len;i>=0;i--){
if (o[i].type == 'file' && o[i].id.indexOf('_upfile') == 0)
{
if (!G('_attachment'+o[i].id.substr(7)))
G('pics').removeChild(o[i]);
}
}
}
function clearAttachment()