Symbolic link not working on server
I deployed a website that's built with Laravel and uses Laravel Nova to manage content, then when I wanted to load the images in the website I created a symbolic link from /storage/app/public to /storage (the /storage folder is created in public_html directory) using the following code:
Route::get('/', function () {
/*create storage symlink*/
$target = $_SERVER['DOCUMENT_ROOT'] . '/../repositories/3ndleeb-app/storage/app/public';
$link = $_SERVER['DOCUMENT_ROOT'] . '/storage';
$sym = symlink($target, $link);
if ($sym) {
return 'symlinked';
}
});
still the images won't load not in the website pages nor in Laravel Nova Dashboard (I made APP_URL=website_url in .env file), but when I delete the symbolic link folder and I replace it with a copy of the /storage/app/public folder it works and the images load successfully. I don't know what's the problem can anyone help me?
Please or to participate in this conversation.