javascript - cant find the right event for a successful upload with ckeditor -


i included custom filemanager ckeditor.
can see working correctly when using built in add image functionality.

the problem: have in custom "bootstrap-carousel" plugin provided image upload functionality.

the goal: built in add image thing activating next or tab after successful upload of image want plugin same. but showing red progress bar although image upload successful on same tab. seems missing upload success event. documentation not provide information filemanger events or not find any.

here code:

ckeditor.editorconfig = function(config){     config.filebrowseruploadurl = '/admin/upload/';     config.filebrowserimageuploadurl = '/admin/upload/';     config.filebrowserbrowseurl = '/admin/upload/?type=browse'; } 

the php router routes requests admin/upload php function:

public function fileupload($params){     $funcnum = $_get['ckeditorfuncnum'];     $url = '';     $error = '';     if($_files['upload']['error'] > 0 ){         switch($_files['upload']['error']){             case 1: $error = 'upload_max_filesize overflow';                 break;             case 2: $error = 'max_file_size overflow';                 break;             case 3: $error = 'file not upload completely';                 break;             case 4: $error = 'no file has been uploaded';                 break;             case 6: $error = 'no temporary folder given.';                 break;             case 7: $error = 'upload aborted: file not been written.';                 break;         }     }     $allowedtypes = array('text/plain','image/jpeg','image/gif', 'image/png');     $type = $_files['upload']['type'];     if(!in_array($type, $allowedtypes)){         $error = 'this file type not allowed';     }     if(file_exists(root_path.'/app/uploads/'.$_files['upload']['name'])){         $error = 'file exists!';     }     if($error === '' && is_uploaded_file($_files['upload']['tmp_name'])){         $upfile = root_path.'/app/uploads/'.$_files['upload']['name'];         if(move_uploaded_file($_files['upload']['tmp_name'], $upfile)){             $url = '/app/uploads/'.$_files['upload']['name'];         }else{             $error .= 'could not move file destination folder!';         }     }        exit("<script type='text/javascript'>window.parent.ckeditor.tools.callfunction($funcnum, '$url', '$error');</script>"); } 

and plugin upload definition:

{             id: 'tab1',             label: 'upload image',             title: 'upload',             elements: [                     {                           type: 'file',                           id: 'upload',                           label: 'select file computer',                           size: 38                       },                       {                           type: 'filebutton',                           id: 'fileid',                           label: 'upload file',                           'for': [ 'tab1', 'upload' ],                           filebrowser: {                                 action: 'quickupload',                                 onselect: function( fileurl, error ) {                                     if(error !== ''){                                        alert(error);                                     }                                    // cancel built in onselect                                    return false;                                 }                                 // here - there should success event ???                                 // on success: function(){} ???                           }                       }             ]         }, 

solution:

onselect: function( fileurl, error ) {             if(error !== ''){                alert(error);             }else{                var document = this.getelement().getdocument();                var element = document.getbyid( 'imgpreview' );                element.sethtml('<img src="'+fileurl+'" style="width:100px"><br />');                var dialog = this.getdialog();                dialog.getcontentelement('tab2','id2').focus();             }             return false;        } 

what thought progress bar uncomplete shown xdebug notice error after upload.

now upload picture , put next tab further treatment , focus on tab.


Comments