Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Added hook: post file upload #340

Closed
wants to merge 1 commit into from

Conversation

prookie
Copy link

@prookie prookie commented Jan 18, 2015

After successfully uploading a file in the panel, the callback function
stored in kirby option variable ‚panel.upload.post‘ is called with the
File object of the newly created file as well as the upload POST data as
arguments (mainly to get access to the original filename in my case)

After successfully uploading a file in the panel, the callback function
stored in kirby option variable ‚panel.upload.post‘ is called with the
File object of the newly created file aswell as the upload POST data as
arguments (mainly to get access to the original filename in my case)
@prookie
Copy link
Author

prookie commented Jan 18, 2015

In my case I used it to save the original file name of the uploaded file in the corresponding meta data of it.

config.php:
c::set('panel.upload.post', function($file, $uploadData) {
    if( is_callable(array($file, 'update')) )
    {
        $file->update(array(
            'originalfilename' => $uploadData['name']
        ));
    }

    // another option: $file->rename(...); etc
});

@bastianallgeier
Copy link
Contributor

We are currently working on a global hook system. So I'm afraid I have to finally close this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants