我使用下面的代码上传文件使用jquery fileapi.Images上传很好,但文档(doc,xls)文件没有上传。在控制台中显示“空文件”(在js代码中wriiten)。请发布。帮助
在图片上传中,test.php文件被调用但是其他人没有调用这个文件。我错过了什么?
标题部分
<script>
FileAPI = {
debug: false,
pingUrl: false,
staticPath: 'dist/'
};
</script>
<script type="text/javascript" src="dist/FileAPI.min.js"></script>
<script type="text/javascript" src="jquery.js"></script>
dist文件夹包含
FileAPI.flash.image.swf,
FileAPI.flash.swf,
FileAPI.min.js,
Javascript函数
function handleAllFileTypesSelect(evt)
{
{
var files = FileAPI.getFiles(evt);
FileAPI.filterFiles(files,function(file, info) {
image_mime = file.type;
console.log(info);
if (/doc|docx|pdf|txt|jpg|jpeg|gif|png|xls|xlsx|ppt|pptx|ods|zip|csv|/.test(file.type) && info) {
return info.width >= 1 && info.height >= 1;
} else {
return file.size > 0;
}
},
function(fileList, ignor) {
if (ignor.length) {
console.log('ignor length:' + ignor.length);
}
if (!fileList.length) {
console.log('empty file list');
return;
}
// do preview
var fileList = FileAPI.filter(fileList, function(file) {
return /doc|docx|pdf|txt|jpg|jpeg|gif|png|xls|xlsx|ppt|pptx|ods|zip|csv|/.test(file.type);
});
j = 0;
FileAPI.each(fileList,function(imageFile) {
FileAPI.upload({
url : 'test.php',
data : {
type : 'pdf',
file_prefix : 'image_',
file_length : fileList.length,
},
files : {
files : FileAPI.filter(fileList,function(file) {
return !/doc|docx|pdf|txt|jpg|jpeg|gif|png|xls|xlsx|ppt|pptx|ods|zip|csv|/.test(file.type);
}),
child_attachments : imageFile
},
complete : function(err, xhr) {
if (!err) {
if ((xhr.responseText).search(/ERROR: File/gi) == -1) {
var response_text_value = xhr.responseText;
response_text_value = response_text_value.replace(/\s/g,'');
alert(response_text_value);
//$('#ifileList').val(val + ','+ response_text_value);
//$('input[type="submit"]').removeAttr('disabled');
}
}
}
});
FileAPI.Image(imageFile).preview(100, 75).get(function(err,image) {
if (err) {
} else {
}
});
});
}
);
} // else
}
</script>
HTML
`<form id="observation_form" class="appnitro" method="post" action="test.php" enctype`="multipart/form-data">
<span class="file-wrapper js-fileapi-wrapper" id="span-image" style="position: relative;">
<input id="logo" name="child_attachments[]" data-preview_id="preview_list" type='file' accept="" multiple />
<span class="button">Attachments</span>
</span>
</form>
<script type='text/javascript'>
document.getElementById('logo').addEventListener('change', handleAllFileTypesSelect, false);
</script>