I am trying to upload/view multiple files with Backpack:5.x
Code for the file upload
Controller
$this->crud->addfield([
'name' => 'files',
'label' => 'Files',
'upload' => true,
'type' => 'upload_multiple',
]);
Model
public function setFilesAttribute($value)
{
$attribute_name = "files";
$disk = "uploads";
$destination_path = "notes";
$this->uploadMultipleFilesToDisk($value, $attribute_name, $disk, $destination_path);
}
config/filessystems.php
'uploads' => [
'driver' => 'local',
'url' => env('APP_URL').'/uploads',
'root' => public_path('uploads'),
],
Problem 1:
Files saved in public/uploads/notes
directory but when I edit an item, the url for the uploaded file is www.test.com/notes/file.txt
getting 404(missing the /**uploads**/notes/file.txt
).
Problem 2: When I am trying to add in list view, I am getting this error –
count(): Parameter must be an array or an object that implements Countable (View: /vendor/backpack/crud/src/resources/views/crud/columns/upload_multiple.blade.php)
$this->crud->addColumn([
'name' => 'files',
'label' => 'Files',
'type' => 'upload_multiple',
]);