Valums文件上传器插件每次都显示上传失败的消息

时间:2013-02-11 18:43:29

标签: javascript jquery fine-uploader

我正在使用valum file uploader。用于初始化插件的js代码是:

function Initializer() {
    var uploader = new qq.FileUploader({
        element: document.getElementById('file-uploader'),
        action: '/_Image/Upload',
        params: {},
        allowedExtensions: ['jpg', 'jpeg', 'png', 'gif'],
        debug: true,
        onSubmit: function (id, fileName) { },
        onProgress: function (id, fileName, loaded, total) { },
        onComplete: function (id, fileName, responseJSON) { },
        onCancel: function (id, fileName) { },
        onError: function (id, fileName, xhr) { },

        messages: {
            typeError: "{file} has invalid extension. Only {extensions} are allowed.",
            sizeError: "{file} is too large, maximum file size is {sizeLimit}.",
            minSizeError: "{file} is too small, minimum file size is {minSizeLimit}.",
            emptyError: "{file} is empty, please select files again without it.",
            allowedExtensionsError : "{file} is not allowed.",
            onLeave: "The files are being uploaded, if you leave now the upload will be cancelled."
        },
        showMessage: function (message) {
            alert(message);
        }
    });
}

文件已成功上传到服务器上,但插件每次都显示file uplode fail消息。 有什么问题?

1 个答案:

答案 0 :(得分:1)

您很可能不会将有效的JSON作为服务器响应返回。在许多地方,自述文件明确指出这是必需的。请看一下自述文件。