A bug with the upload images
config.jsThat the editor take the url that I response and put the image in the editor.
I read this tutorial
I get this error:
Installed CKEditor plugins: Enhanced Image and Office 2013
My file config.js :
/**
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
*/
CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
config.language = 'es';
//config.toolbarCanCollapse = true;
config.uiColor = '#FFFFFF';
config.height = 500;
config.filebrowserUploadUrl = '/Pages/HE/SHE00000/UploadCKEditorFiles.aspx?type=Files';
config.filebrowserImageBrowseUrl = '/Pages/HE/SHE00000/UploadCKEditorFiles.aspx?type=Image';
config.filebrowserFlashBrowseUrl = '/Pages/HE/SHE00000/UploadCKEditorFiles.aspx?type=Flash';
config.toolbarGroups = [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
{ name: 'clipboard', groups: [ 'undo', 'clipboard' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
{ name: 'forms', groups: [ 'forms' ] },
'/',
{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
{ name: 'links', groups: [ 'links' ] },
{ name: 'insert', groups: [ 'insert' ] },
'/',
{ name: 'styles', groups: [ 'styles' ] },
{ name: 'colors', groups: [ 'colors' ] },
{ name: 'tools', groups: [ 'tools' ] },
{ name: 'others', groups: [ 'others' ] },
{ name: 'about', groups: [ 'about' ] }
];
config.removeButtons = 'PasteFromWord,Templates,About,Save,Form,Iframe';
};
Try changing config.filebrowserUploadMethod to form.
Starting from CKEditor 4.9.0 all file uploads (including the one initiated by the filebrowser plugin) expect json response similar to this one: https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-uploaded-successfully, unless you change the mentioned config option back to form.
Yes, the solution is that.
I change mi vb.net code for this, in the return.
I create a class:
```vb.net
Public Class responseJSON
Private _fileName As String
Private _uploaded As Integer
Private _url As String
Public Property fileName() As String
Get
Return Me._fileName
End Get
Set(ByVal value As String)
Me._fileName = value
End Set
End Property
Public Property uploaded() As Integer
Get
Return Me._uploaded
End Get
Set(ByVal value As Integer)
Me._uploaded = value
End Set
End Property
Public Property url() As String
Get
Return Me._url
End Get
Set(ByVal value As String)
Me._url = value
End Set
End Property
End Class
```vb.net
Dim baseUrl As String = "/Images/imagesManual/"
Dim basePath As String = Server.MapPath("~" & baseUrl)
' Done. Now test it!
' No need to modify anything below this line
'----------------------------------------------------
' ------------------------
' Input parameters: optional means that you can ignore it, and required means that you
' must use it to provide the data back to CKEditor.
' ------------------------
' Optional: instance name (might be used to adjust the server folders for example)
Dim CKEditor As String = HttpContext.Current.Request("CKEditor")
' Required: Function number as indicated by CKEditor.
Dim funcNum As String = HttpContext.Current.Request("CKEditorFuncNum")
' Optional: To provide localized messages
Dim langCode As String = HttpContext.Current.Request("langCode")
' ------------------------
' Data processing
' ------------------------
Dim total As Integer
Try
total = HttpContext.Current.Request.Files.Count
Catch ex As Exception
'Return sendError("Error uploading the file")
End Try
If (total = 0) Then
'Return sendError("No file has been sent")
End If
If (Not System.IO.Directory.Exists(basePath)) Then
'Return sendError("basePath folder doesn't exists")
End If
'Grab the file name from its fully qualified path at client
Dim theFile As HttpPostedFile = HttpContext.Current.Request.Files(0)
Dim strFileName As String = theFile.FileName
If (strFileName = "") Then
'Return sendError("File name is empty")
End If
Dim sFileName As String = System.IO.Path.GetFileName(strFileName)
If (sFileName.Length > 50) Then
sFileName = sFileName.Substring(0, 50)
End If
Dim name As String = System.IO.Path.Combine(basePath, sFileName)
theFile.SaveAs(name)
Dim url As String = baseUrl + sFileName.Replace("'", "\'")
' ------------------------
' Write output
' ------------------------
json.fileName = sFileName
json.uploaded = total
json.url = url
Response.Write(JsonConvert.SerializeObject(json))
I don't know how response error message.
I'll read this page, i hope know how send the message error in the JSON
https://docs.ckeditor.com/ckfinder/ckfinder3-php/commands.html
But the problem with the load images is solved
Here you have the sample json response with an error message:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-could-not-be-uploaded
and here with files that uploaded correctly:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-uploaded-successfully
@wwalc Thanks, it's all :relaxed:
Thk, my friend, you saved my ass
Here you have the sample json response with an error message:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-could-not-be-uploaded
and here with files that uploaded correctly:
https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-uploaded-successfully
@wwalc thanks you!
in ckeditor file root in config.js file you should have this line in editorConfig like this
CKEDITOR.editorConfig = function( config ) {
config.filebrowserUploadMethod = 'form';
};
Most helpful comment
Try changing config.filebrowserUploadMethod to
form.Starting from CKEditor 4.9.0 all file uploads (including the one initiated by the filebrowser plugin) expect json response similar to this one: https://docs.ckeditor.com/ckeditor4/latest/guide/dev_file_upload.html#response-file-uploaded-successfully, unless you change the mentioned config option back to
form.