Search code examples
phplaravellaravel-5.8

Where is storage_path('/app/public/') located exactly


I want to run this code via command line:

public function handle()
    {
        if ( ! File::exists(storage_path('/app/public/examResult/' . $this->argument('file'))) ) {
            dd('Not found this file!');
        }

        Excel::import(new ImportsExamResultImport(), storage_path('/app/public/examResult/' . $this->argument('file')));

        dd('Import excel was successfully');
    }

So it basically reads an Excel file which is located at storage_path('/app/public/examResult/') directory.

So I placed my Excel file at laravelproject/app/public/examResult but when I run the command to execute it, I get this message:

Not found this file!

So the question is, where exactly storage_path ? Am I putting the file in the right place ?


Solution

  • When you set up a new project you will want to run :

    php artisan storage:link
    

    That sets up a symbolic link from laravelproject/public/storage to laravelproject/storage

    storage_path('/app/public')
    

    can be found at :

    laravelproject/storage/app/public