Pergunta

I am using uploadify.js for image upload functionality.

But when I select invalid file type, it shows a blank alert message.

Where should I edit the file to display message as un supported file type?

I have following type of code in uploadify.js file.

// Run the default event handler
            if ($.inArray('onSelectError', settings.overrideEvents) < 0) {
                switch(errorCode) {
                    case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED:
                        if (settings.queueSizeLimit > errorMsg) {
                            this.queueData.errorMsg += '\nThe number of files selected exceeds the remaining upload limit (' + errorMsg + ').';
                        } else {
                            this.queueData.errorMsg += '\nThe number of files selected exceeds the queue size limit (' + settings.queueSizeLimit + ').';
                        }
                        break;
                    case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
                        this.queueData.errorMsg += '\nThe file "' + file.name + '" exceeds the size limit (' + settings.fileSizeLimit + ').\nPlease upload the file in specified size limit.';
                        break;
                    case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE:
                        this.queueData.errorMsg += '\nThe file "' + file.name + '" is empty.';
                        break;
                    case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
                        this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';


break;
            }

I noticed that this SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: is used two times.

I think I need to change FILE_EXCEEDS_SIZE_LIMIT to something else for invalid filetype. But do not know what to write there?

Foi útil?

Solução

I replaced the

case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT:
                        this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';

with this

   case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: 
                        this.queueData.errorMsg += '\nThe file "' + file.name + '" is not an accepted file type (' + settings.fileTypeDesc + ').';

and the problem solved.

This is a bug in jquery.uploadify.js

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top