#Beginner Image Upload Question

6 messages · Page 1 of 1 (latest)

toxic geyser
#

I have a form that accepts 1 or more file uploads.
I defined a custom folder/filesystem:

        'market' => [
            'driver' => 'local',
            'root' => storage_path('app/public/market/images'),
            'url' => env('APP_URL').'/storage/market',
            'visibility' => 'public',
            'throw' => false,
        ],

In my controller I have:

            $newName = $file->hashName();
            $storedPath = $file->storePubliclyAs($file, $newName, 'market');
            echo $storedPath;
        }

The file that is being saved is going under 'tmp' folder instead of the exact folder mentioned. How do I store the file as defined in the controller?

toxic geyser
#

I changed the controller code to:

        foreach ($request->file('files') as $file) {
            $newName = $file->hashName();
            $file->storeAs('public/market/images', $newName);```
and it seems to be working, however, how can I avoid hardcoding 'public/market/images' ?
dry dock
#

at .env set the variable FILESYSTEM_DISK=market

toxic geyser
#

There isn't a way to get it directly from my filesystems.php config?

dry dock
#

so that, you only need to make changes at the config/filesystem.php