Is there a way to get a notification via PHP, or Javascript when a user Uploads a new file?
I would like to get the name of the new file uploaded and save it to a database, while also keeping track of the # of files that were uploaded.
I would like to get the name of the new file uploaded and save it to a database, while also keeping track of the # of files that were uploaded.
Re: Attaching Upload Function to a Callback
-- File Upload - To Run custom code when a file is uploaded
open up the file:
/ckfinder/core/connector/php/php5/CommandHandler/FileUpload.php
if you want something to happen when a file uploads without a problem, look for the switch statement and add it within the case "UPLOAD_ERR_OK"
I wanted to prevent users from uploading files, to limit the # of uploaded files they can have.
So within FileUpload.php just before the switch statement I added the following, which when evaluates to
true it will throw an error, and ckfinder will stop processing the upload:
-- Delete File custom code
open up the file:
/ckfinder/core/connector/php/php5/CommandHandler/DeleteFile.php
within the last if statement, where the bDeleted statement will be true add your code:
I also set up the custom error message here:
-- To Create a Custom Error Message
open up the file:
ckfinder/core/connector/php/lang/en.php
Add an error to the array
open up the file:
ckfinder/core/connector/php/constants.php
Add a global constant and match it to the # '987' of whatever you used in the step above.
Re: Attaching Upload Function to a Callback
Alternatively, instead of modifying CKFinder core you may try writing a PHP extension and use for example onBeforeExecuteCommand or AfterFileUpload hooks.
Wiktor Walc
CTO, CKSource - http://cksource.com
--
Follow CKEditor on: Twitter | Facebook | Google+