Reputation: 33
Developers. I am working on an API project and there is image uploading in many pages, and I was storing the images like this
public function store(StorePlatformRequest $request)
{
$request->validated($request->all());
$filePath = $request->file('logo')->store('platforms_logos', 'public');
$platform = Platform::create([
'name' => $request->name,
'logo' => Storage::url($filePath),
]);
return new PlatformResource($platform);
}
and for example the logo image field in the database is storing a value like this
/storage/platforms_logos/wg3p4shWA3C9GGDEca4fDFSezVNn5eNWZsaD45HO.png
Now I uploaded my project on a shared hosting and the old images that was uploaded when I was working on local is retrieving successfully and working fine because I changed the localhost URL in the frontend pages to retrieve the links from the deployed app
But somehow when I am calling any function that includes image uploading it's not working, the image is uploaded successfully in the storage/app/public folders and the name of it is stored in the database, but I can't retrieve it anymore.
And when I tried to access the image directly from the browser it said 404 not found, but it's uploaded successfully in the folder
I thought it might be storage link problem and added this to web.php file and called it
Route::get('storage_link', function () {
\Artisan::call('storage:link');
dd("Storage is linked");
});
But nothing solved
Can any one help me with what I am missing?
Upvotes: 0
Views: 43
Reputation: 193
Delete the folder public>storage first and then execute storage_link function
Upvotes: 0