Plupload Catching Uncaught WRONG_FORMAT

37 Views Asked by At

Using Plupload v2.1.2

An image says it all. Essentially, if adding a corrupted JPEG file, or adding a file with in invalid (not accepted) mime-type that was simply renamed to a "valid" extension, then I'm getting an uncaught "WRONG_FORMAT" error. How could I catch it and have Plupload show a valid error message, like it does for the max_file_size filter, or invalid file extension ?

Uncaught error when wrong_format

My code so far:

// Initialize the widget when the DOM is ready
$(function() {

    $("#uploader").plupload({

        // General settings
        runtimes : 'html5,html4',
        url : "index.cfm?fa=MediaMod.CreateMediaFile",
        
        chunk_size: '1mb',

        filters : {
            // Maximum file sizes
            max_file_size : '1mb',
 
            // Specify what files to browse for
            mime_types: [
                {title : "Image files", extensions : "jpg,jpeg,gif,png"}
            ]
        },

        // Rename files by clicking on their titles
        rename: true,

        // Sort files
        sortable: true,

        // Enable ability to drag'n'drop files onto the widget (currently only HTML5 supports that)
        dragdrop: true,

        // Views to activate
        views: {
            list: true,
            thumbs: true, // Show thumbs
            active: 'thumbs'
        },

        init : {

            // Fires when a error occurs.
            Error: function(uploader, error) {
                if (error.status == 400) {
                    console.warn("File failed: " + error.file.name);
                }
                else {
                    // re-throw...? 
                }
            }

        }
    });

    $("#uploader").on("complete", function() {
        window.parent.closePopWin();
    });
});

Appreciate your help. Pat

0

There are 0 best solutions below