有什么解决方案可以在octopercms的后端获取刚刚上传的图像的完整文件路径吗?
我需要在afterCreate()中粘贴图像url。当我使用$image->getPath()
时,我得到以下错误:"在非对象上调用成员函数getPath()"
如果我尝试$request->file('featured_image')
,还可以给我"在非对象上调用成员函数文件()"
我还尝试了Input::file('featured_image')->getRealPath()
,它也给了我"在非对象上调用成员函数getRealPath()"
有没有办法在后台获取刚刚上传的图像的完整文件路径?
这样的东西应该能起作用,尽管我不是100%清楚这是你真正想要实现的。
以下是示例插件类声明的样子:
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();
});
});
}
}