Reputation: 807
Is there any solution to get the full file path of a just uploaded image in the backend of octobercms?
I need to paste the image url in afterCreate() When I use $image->getPath()
I get the follow error: "Call to a member function getPath() on a non-object"
If i try $request->file('featured_image')
give me also the "Call to a member function file() on a non-object"
I try also Input::file('featured_image')->getRealPath()
what give me also "Call to a member function getRealPath() on a non-object"
Is there any way to get the full file path of a just uploaded image in the backend?
Upvotes: 0
Views: 760
Reputation: 54
Something like this should work although I'm not 100% clear this is what you're actually trying to achieve.
Here's what a sample plugin class declaration would look like:
class Plugin extends PluginBase
{
public function boot()
{
// Bind to afterCreate
File::extend(function($model) {
$model->bindEvent('model.afterCreate', function() use ($model) {
// Do whatever with $model->getPath();
});
});
}
}
Upvotes: 1