Symlink doesn't work in production I try to upload images to my public folder but somehow in production it does not work. The image is saved to the storage/company folder but I cant access it in the public folder of my app.
filesystem.php
'links' => [
public_path('storage') => storage_path('app/public'),
public_path('company') => storage_path('app/company'),
],
service class
public function uploadFile(UploadedFile|File $logo): ?String
{
return Storage::putFile('company/logos', $logo);
}
I also ran the php artisan storage:link in forge but no success. Maybe someone could help here?
Start by checking on the server if the symlink has been created. You can also try deleting the directory in /public/storage, and running php artisan storage:link again
@Sinnbeck It says symlink has been created. Also deleted the storage folder no success.
The strange thing locally everything works just fine.
@SmokeTM Check it manually on the server. Make a file in the /storage/app/public folder and see if it shows up in /public/storage
@Sinnbeck ok thats strange the public folder works but not the company folder.
Has that something to do with the rights?
@Sinnbeck The company folder yes but not the logos folder and the image.
@SmokeTM did you try deleting it and the storage folder and redo storage link?
@Sinnbeck I mistakenly deleted the app/storage folder. Is it possible to restore them somehow? Command or something?
@SmokeTM on production? You need to restore your backup of the folder. If it's shared hosting maybe they have backups
@Sinnbeck I reinstalled everything now but storage link doesn't work anyways. Don't know what to do now? Yes on production.
@SmokeTM so only one of them is created? Does it work locally? Laravel version?
@Sinnbeck yes it looks like so. It works perfectly fine locally. Laravel version is 9.24.0
@SmokeTM ok so the folders are removed in /public but are present in /storage? You run the link command and both folders show up in /public?
@Sinnbeck It works now thank you so much!! Deleted company and storage folder in public and ran the storage:link command, now it works.
Please sign in or create an account to participate in this conversation.