0

I write a function in my medium model to get the visibility of files and I did that that with accessors

my function :

public function getVisibilityAttribute()
{
 return Storage::getVisibility(storage_path('app/' . $this->getOriginal('path')));
// the path comes from database and here is 'public/test/user.jpg'
}

after I fetch my data from database to show the files , I get this error :

exception: "League\Flysystem\FileNotFoundException"
file: "C:\xampp\htdocs\admin\vendor\league\flysystem\src\Filesystem.php"
line: 389
message: "File not found at path: C:/xampp/htdocs/admin/storage/app/public/test/user.jpg"

but the user.jpg exists at that path and i can access the image by browser .

so what should i do to solve this error?

sajadsholi
  • 173
  • 1
  • 3
  • 12
  • Does this answer your question? [Laravel File not found at path but it does exist](https://stackoverflow.com/questions/44769693/laravel-file-not-found-at-path-but-it-does-exist) – Salim Ibrohimi Apr 25 '20 at 12:01

1 Answers1

0

you can first check if you run

php artisan storage:link

Then this works fine:

return Storage::disk('public')->getVisibility('test.txt');

File location in:

/storage/app/public/test.txt

Adapt your getVisibilityAttribute function accordingly and can try it out.

Saibal Roy
  • 413
  • 2
  • 5