Search code examples
javascriptjqueryfine-uploader

Valums file uploader plugin shows upload failed message each time


I am using valum file uploader. The js code for initializing plugin is:

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);
        }
    });
}

The file is successfully uploaded on the server but the plugin is showing the file uplode fail message each time. What's the issue?


Solution

  • You are most likely not returning valid JSON as your server response. The readme clearly states, in many places, that this is required. Please have a look at the readme.