Krajee Bootstrap文件上传插件仅接受图像文件类型

时间:2016-03-09 23:10:07

标签: javascript php jquery

我正在尝试使用krajee bootstrap file upload进行excel(.xls)文件上传,但似乎只接受图片文件。

这是我的Javascript代码:

            $("#dosyalar").fileinput({
                    uploadUrl: "ajax/upload_files.php",
                    uploadAsync: true,
                    previewFileType:'any',
                    language:"tr",
                    uploadExtraData: function() {
                        return { donem: $('#donem').val() };
                    }
                }).on('filebatchuploaderror', function(event, data, previewId, index) {
                    var form = data.form,
                        files = data.files,
                        extra = data.extra,
                        response = data.response,
                        reader = data.reader;
                    console.log(response);

            }).on('filebatchuploadsuccess', function(event, data, previewId, index) {
                    var form = data.form,
                        files = data.files,
                        extra = data.extra,
                        response = data.response,
                        reader = data.reader;
                    alert (extra.bdInteli + " " +  response.uploaded);
                    console.log(response);
            });

此处用于测试的PHP代码:

// upload.php
// 'images' refers to your file input name attribute
if (empty($_FILES['dosyalar'])) {
    echo json_encode(['error'=>'No files found for upload.']);
    // or you can throw an exception
    return; // terminate
}

每次说No files found for upload时尝试上传批处理Excel文件。似乎不接受.xls扩展名。

如何使用此插件上传excel文件?

由于

1 个答案:

答案 0 :(得分:0)

您是否指定了扩展名? allowedFileExtensions:['jpg','png','gif','xlsx']