Reputation: 13
I'm having trouble with image upload at the backend with octoberCMS. The image actually uploads, but I need to save the image path along with my model. I'm not able to get the full path, at most all I'm able to get is:
/storage/app/uploads/public//
Please how do I obtain the full path to the uploaded image?
Upvotes: 0
Views: 1567
Reputation: 57
If you want to get path from media manager section by using media finder uploader object; you can use this code.
Config::get('cms.storage.media.path')
Upvotes: 0
Reputation: 11
Add function to your model :
public function getAll(){
return self::get();
}
After add onInit() function in your page :
function onInit() {
$model = new Author\PluginName\Models\ClassName(); // change path to your model
$this['alldata']= $model->getAll();
}
After that you get all data with image on your page. You can get image path this way :
{% for item in alldata %}
{{ item.fileupload1.path}} // change 'fileupload1' to your file input name
{% endfor %}
Upvotes: 0