skip to Main Content

I’m trying to get an image from the web and store it locally in my ‘app/library’ folder using Laravel 9. After battling for an hour with get_file_contents, I finally discovered guzzler and the file is fetched properly. Now I’m trying to save it using the following command.

$stored = Storage::put(storage_path('app/library').'/'.$filename, $content)'

$stored shows as ‘1’, which leads me to think that it’s worked, but the file is not in my app/library folder. Nor can I find any file with the correct name anywhere in my project.

Is there something wrong with my command?

2

Answers


  1. Chosen as BEST ANSWER

    Thanks to lagbox for the answer. I was overthinking it and didn't need 'storage_path()'. The following worked.

    $stored = Storage::put('library/'.$filename, $content)'
    

Please signup or login to give your own answer.
Back To Top
Search