I've been searching for a plugin to provide the <input type="file" ...> and could not find one. So, I set out to come up with one. I'm almost there by piecing together different plugins and code snippets. I can make a new one but when double clicking the file input it comes up as a text field and not the file input. Can someone take a look at this and see what I'm missing?
file: plugin.js
file: fileupload.js
ANY help is MUCH appreciated. I've been fooling with this for a few days.
Thanks,
Steffan
file: plugin.js
CKEDITOR.plugins.add('fileupload', { requires: ['fileupload'], lang : ['en'], init:function(a) { var b="fileupload"; var c=a.addCommand(b,new CKEDITOR.dialogCommand(b)); c.modes={wysiwyg:1,source:0}; c.canUndo=false; a.ui.addButton("fileupload",{ label:a.lang.fileupload.title, command:b, icon:this.path+"upload.gif" }); CKEDITOR.dialog.add(b,this.path+"dialogs/fileupload.js")} });
file: fileupload.js
CKEDITOR.dialog.add('fileupload',function(a) { return { title:a.lang.fileupload.title, minWidth:280, minHeight:150, onOk : function(editor) { var element = editor.element, isInsertMode = !element; if ( isInsertMode ) { editor = this.getParentEditor(); element = editor.document.createElement( 'input' ); element.setAttribute( 'type', 'file' ); } if ( isInsertMode ) editor.insertElement( element ); this.commitContent( { element : element } ); }, contents:[ { id:'info', label:'', title:'', expand:true, padding:0, elements:[ { id : 'txtName', type : 'text', label : a.lang.fileupload.name, 'default' : '', accessKey : 'N', setup : function( element ) { this.setValue( element.data( 'cke-saved-name' ) || element.getAttribute( 'name' ) || '' ); }, commit : function( data ) { var element = data.element; // IE failed to update 'name' property on input elements, protect it now. if ( this.getValue() ) element.data( 'cke-saved-name', this.getValue() ); else { element.data( 'cke-saved-name', false ); element.removeAttribute( 'name' ); } } }, { id : 'txtAccept', type : 'text', label : a.lang.fileupload.accept, 'default' : '', accessKey : 'A', setup : function( element ) { var value = element.getAttribute( 'accept' ); this.setValue( value ); }, commit : function( data ) { var element = data.element, value = this.getValue(); if ( value ) element.setAttribute( 'accept', value ); else element.removeAttribute( 'accept' ); } }, { id : 'size', type : 'text', label : 'Size / Character Width', 'default' : '20', accessKey : 'C', style : 'width:50px', //validate : CKEDITOR.dialog.validate.integer( editor.lang.common.validateNumberFailed ) setup : function( element ) { var value = element.getAttribute( 'size' ); this.setValue( value ); }, commit : function( data ) { var element = data.element, value = this.getValue(); if ( value ) element.setAttribute( 'size', value ); else element.removeAttribute( 'size' ); } } ] }], buttons:[CKEDITOR.dialog.okButton,CKEDITOR.dialog.cancelButton] }; });
ANY help is MUCH appreciated. I've been fooling with this for a few days.
Thanks,
Steffan
Re: Plugin for <input type="file" ...
Suggestions?
Re: Plugin for <input type="file" ...
Does anyone have any experience with writing plugins for this? It seems like a popular product but its odd that something like a file input is so hard to do.
Anyone?