Laravel Images Not Showing on cPanel? Fix It in 2 Minutes
You uploaded your Laravel project to cPanel. Everything works, but the uploaded images don't show. You only see broken image icons.
Why it happens
Laravel saves uploaded files in storage/app/public. Browsers can only see them through a link called public/storage. That link doesn't upload with your files, so it doesn't exist on the server.
Fix 1: With Terminal
Open Terminal in cPanel and run:
cd ~/your-project php artisan storage:link Refresh your site. Images should now load.
Fix 2: Without Terminal
Add this route to routes/web.php:
Route::get('/make-link', function () { Illuminate\Support\Facades\Artisan::call('storage:link'); return 'Done'; }); Open yourdomain.com/make-link once. Then delete the route so nobody else can use it.
Still not working?
- Check that
APP_URLin.envis your real domain, likehttps://yourdomain.com. - Some hosts block links. Ask support to allow symlinks.
Need help with your Laravel project on cPanel? I fix deployment issues here: https://www.fiverr.com/s/YLLm23N
原文:https://www.a8q9.cn/en/article/laravel-images-not-showing-on-cpanel-fix-it-in-2-minutes-e72f8f.html