QuickUpload"

This website contains links to software which is either no longer maintained or will be supported only until the end of 2019 (CKFinder 2). For the latest documentation about current CKSource projects, including software like CKEditor 4/CKEditor 5, CKFinder 3, Cloud Services, Letters, Accessibility Checker, please visit the new documentation website.

If you look for an information about very old versions of CKEditor, FCKeditor and CKFinder check also the CKEditor forum, which was closed in 2015. If not, please head to StackOverflow for support.

 
(One intermediate revision by one other user not shown)
Line 2: Line 2:
 
== QuickUpload ==
 
== QuickUpload ==
  
Adds a file in a folder. It generates a POST. <br>This command is pretty similar to the [[CKFinder/Server Side Integration/The Commands/FileUpload|FileUpload]] command. It is used by FCKeditor 2.5.
+
Adds a file in a folder. <br>This command is pretty similar to the [[CKFinder/Server Side Integration/The Commands/FileUpload|FileUpload]] command. It is used by FCKeditor 2.x and CKEditor 3.x. There are some differences between data that is sent by FCKeditor and CKEditor (and expected response), please read documentation below carefully.
  
 
=== Sample Request ===
 
=== Sample Request ===
Line 8: Line 8:
 
Upload a file in the root directory of the resource type “Files”.
 
Upload a file in the root directory of the resource type “Files”.
 
<pre>connector.php?command=QuickUpload&amp;type=Files&amp;currentFolder=%2F</pre>
 
<pre>connector.php?command=QuickUpload&amp;type=Files&amp;currentFolder=%2F</pre>
The request will be done using POST (instead of GET) and the data will encoded in “multipart/form-data”. Only one field will be posted, named “NewFile”, containing the file uploaded data.
+
The request will be done using POST (instead of GET) and the data will encoded in “multipart/form-data”. Only one field will be posted, named '''“NewFile” (FCKeditor) or “upload” (CKEditor)''', containing the file uploaded data.
  
=== Sample Response ===
+
=== Response ===
 +
 
 +
This command doesn’t expect XML to be returned. Actually HTML must return with a &lt;script&gt; tag. The content type must be “text/html”. The JavaScript code expected by CKEditor and FCKeditor is different.
 +
 
 +
=== Sample Response (FCKeditor) ===
 
<pre>&lt;script type="text/javascript"&gt;
 
<pre>&lt;script type="text/javascript"&gt;
 
window.parent.OnUploadCompleted(0, '/ckfinder/userfiles/files/filename.txt', 'filename.txt', '') &nbsp;;
 
window.parent.OnUploadCompleted(0, '/ckfinder/userfiles/files/filename.txt', 'filename.txt', '') &nbsp;;
 
&lt;/script&gt;</pre>
 
&lt;/script&gt;</pre>
<br>This command doesn’t expect XML to be returned. Actually HTML must return with a &lt;script&gt; tag. The content type must be “text/html”. The "OnUploadCompleted" is a JavaScript function that is called to expose the upload result.
+
<br>The "OnUploadCompleted" is a JavaScript function that is called to expose the upload result.
  
 
The possible values are:
 
The possible values are:
Line 23: Line 27:
  
 
Note that uploaded file names may contain non ASC-II chars.
 
Note that uploaded file names may contain non ASC-II chars.
 +
 +
=== Sample Response (CKEditor) ===
 +
 +
CKEditor sends some additional parameters when sending the QuickUpload command:
 +
<pre>connector.php?command=QuickUpload&type=Images&currentFolder=%2F&CKEditor=editor1&CKEditorFuncNum=2&langCode=en</pre>
 +
* CKEditor - the name of the CKEditor instance
 +
* langCode - the current language code
 +
* CKEditorFuncNum - a parameter to specify the callback function
 +
(see: [[CKEditor_3.x/Developers_Guide/File_Browser_(Uploader)/Custom_File_Browser|Custom File Browser]])
 +
 +
There are no special error numbers in the callback function. Your script can return a url to use and a message to show to the user, both are optional so you can return just an URL that will be used in the dialog, or you can return a message that will be shown to the user, or a URL and a message (for example a warning that the file has been renamed and the new URL).
 +
 +
Thanks to the message and the "langCode" parameter you can use localized messages instead of having them in English.
 +
 +
<pre><script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(funcNum, fileUrl, message)</script></pre>

Latest revision as of 07:46, 28 May 2010

Note: This information is intented for programmers interested in modifying the CKFinder core.
If you are interested in installing/configuring CFKinder, please take a look at the Developer's Guide.

QuickUpload

Adds a file in a folder.
This command is pretty similar to the FileUpload command. It is used by FCKeditor 2.x and CKEditor 3.x. There are some differences between data that is sent by FCKeditor and CKEditor (and expected response), please read documentation below carefully.

Sample Request

Upload a file in the root directory of the resource type “Files”.

connector.php?command=QuickUpload&type=Files&currentFolder=%2F

The request will be done using POST (instead of GET) and the data will encoded in “multipart/form-data”. Only one field will be posted, named “NewFile” (FCKeditor) or “upload” (CKEditor), containing the file uploaded data.

Response

This command doesn’t expect XML to be returned. Actually HTML must return with a <script> tag. The content type must be “text/html”. The JavaScript code expected by CKEditor and FCKeditor is different.

Sample Response (FCKeditor)

<script type="text/javascript">
window.parent.OnUploadCompleted(0, '/ckfinder/userfiles/files/filename.txt', 'filename.txt', '')  ;
</script>


The "OnUploadCompleted" is a JavaScript function that is called to expose the upload result.

The possible values are:

  • OnUploadCompleted( 0 , "/full/path/to/the/filename.txt", "filename.txt" ); : no errors found on the upload process.
  • OnUploadCompleted( 1, "", "", "Reason" ); : the upload filed because of "Reason". Note: no paths being sent here, because uploading failed.
  • OnUploadCompleted( 201 , "/full/path/to/the/filename.txt(1)", "filename.txt(1)" ); : the file has been uploaded successfully, but its name has been changed to "filename(1).ext".

Note that uploaded file names may contain non ASC-II chars.

Sample Response (CKEditor)

CKEditor sends some additional parameters when sending the QuickUpload command:

connector.php?command=QuickUpload&type=Images&currentFolder=%2F&CKEditor=editor1&CKEditorFuncNum=2&langCode=en
  • CKEditor - the name of the CKEditor instance
  • langCode - the current language code
  • CKEditorFuncNum - a parameter to specify the callback function

(see: Custom File Browser)

There are no special error numbers in the callback function. Your script can return a url to use and a message to show to the user, both are optional so you can return just an URL that will be used in the dialog, or you can return a message that will be shown to the user, or a URL and a message (for example a warning that the file has been renamed and the new URL).

Thanks to the message and the "langCode" parameter you can use localized messages instead of having them in English.

<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction(funcNum, fileUrl, message)</script>
This page was last edited on 28 May 2010, at 07:46.