我需要在onSelect事件中验证所选文件,并根据修改Uplodify元素的内容,例如更改为错误样式并隐藏进度并在百分比div中添加一些描述!
问题是它在onSelect事件中没有找到关于Uplodify内容的任何内容!!!
这个问题有什么解决方案吗?
我的代码在这里:
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=\"" + $error_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>" );
}
}
});
这些代码行不起作用: $($ idSelector + ID).find('。percentage')。text(“ - ”+ $ error_msg +“Error”); $($ idSelector + ID).find('。uploadifyProgress')。hide(); $($ idSelector + ID).addClass('uploadifyError');
有什么解决方案吗?