开发者

Uplodify onSelect event problem!

I need to validate selected file in onSelect event and according to that modify content of Uplodify element for example change to error style and hide progress and add some description in percentage div!

problem is that it not find anything about Uplodify content in onSelect event!!!

there is any solution for this problem?

my code is here :

var $max_file_size = 1024000;
var $arr_allow_extention = ['.jpg', '.gif', '.png'];
//console.log($arr_allow_extention);
$($idSelector).uploadify({
    'uploader'  : $project_public_path + '/share/library/uploadify/uploadify.swf',
    'script'    : $project_public_path + '/share/library/uploadify/uploadify.php',
    'cancelImg' : $project_public_path + '/share/library/uploadify/cancel.png',
    'folder'    : $project_public_path + '/uploaded_resource/bug',
    'sizeLimit' : $max_file_size, // 10 MB
    'auto'      : false,
    'buttonText'  : ' Browse ',
    'fileExt'     : '*.jpg;*.gif;*.png',
    'fileDesc'    : 'Web Image Files (.JPG, .GIF, .PNG)',
    'removeCompleted' : false,

      'onSelect'    : function(event, ID, fileObj) {
        var $has_error = false;
        var $error_msg = '';

        $( $idSelector ).removeAttr('title').removeClass();
        $( $idSelector ).parent().find('.check-ok, .check-error').remove();

        if (fileObj.size >= $max_file_size) {
            //console.log( 'size is over!' ); 
            $has_error = true;
            $error_msg += 'Maximum file size reached!';
        }

        if ( $.inArray(fileObj.type, $arr_allow_extention) ) {
            $has_error = true;
            $error_msg += 'Extention not allowed';

            $($idSelector + ID).find('.percentage').text(" - " + $error_msg + " Error");
            $($idSelector + ID).find('.uploadifyProgress').hide();
            $($idSelector + ID).addClass('uploadifyError');
        }

        if ( $has_error ) {
            $('#img-upload-btn').remove();
            $($idSelector).text('');
            $( $idSelector ).addClass('error');
            $( $idSelector ).after( "<span class=\"check-error\" title=\"" + $erro开发者_Go百科r_msg + "\"></span>" );
        } else {
            $('#imgQueue').before( "<span id=\"img-upload-btn\" title=\"Press to upload\" class=\"button\"><img src=\"" + $project_public_path + "/share/library/uploadify/upload-btn.jpg\" style=\"display:none;\" /></span>" );

            $('#img-upload-btn').click(function(){
                //console.log( ID );
                $($idSelector).uploadifyUpload( ID );
            });
            $( $idSelector ).after( "<span class='check-ok'></span>" );
        }

    }       
});

these line of code not work : $($idSelector + ID).find('.percentage').text(" - " + $error_msg + " Error"); $($idSelector + ID).find('.uploadifyProgress').hide(); $($idSelector + ID).addClass('uploadifyError');

there is any solution?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜