Reading image from storage_path on a shared host e.g Godaddy, returning error 404

时间:2019-04-17 01:34:29

标签: laravel

I have a problem reading the url of the file saved to Storage/app/uploads/images/ on goDaddy shared host.

in .env, I configure the APP_URL = www.piggystore.com/server/storage

in a filesystem.php, after running php artisan storage:link When I upload, the image is stored in Storage/app/uploads/images but to retrieve it is the problem. I have configured public_path, by changing it in filesystem.php but it is not working as well. What am I getting wrong.

.env file

 'disks' => [

        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
        ],

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

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
        ],

    ],

];

Saving files in the path

$saveme = storage_path('app/uploads/images/'.$exportName);
            $background->save($saveme);
            $imag->image = $exportName;
            $imag->textwrap = "dev";
            $imag->imageOption = $option;
            $imag->save(); 
                if (empty($imag)){
                    return response()->json([
                        'success' => false,
                        'message' => 'There was a problem creating the postcard!'
                    ], 201);
                }

                 return response()->json([
                       'success' => true,
                       'data' => storage_path('app/uploads/images/'.$exportName),
                       'message' => 'Postcard created successfully!'
                   ]);

                }

All I want is to www.piggystore.com/uploads/images/filename.extension which will display in the browser

Thanks in advance

0 个答案:

没有答案