Php Laravel不显示url中的图像
我在共享主机上访问存储中的一些图像时遇到问题 例如:Php Laravel不显示url中的图像,php,laravel,storage,Php,Laravel,Storage,我在共享主机上访问存储中的一些图像时遇到问题 例如:/storage/captcha/baa5271fe19d696d6e83388a5c22f13c40ecc470.jpg显示html页面,但/storage/images/slider1.jpg显示图像 干预\Image\Facades\Image用于生成验证码图像 要比较的filesystems.php配置: “验证码”=>[ “驱动程序”=>“本地”, 'root'=>存储路径('app/public/captcha'), 'url'=>
/storage/captcha/baa5271fe19d696d6e83388a5c22f13c40ecc470.jpg
显示html页面,但/storage/images/slider1.jpg
显示图像
干预\Image\Facades\Image
用于生成验证码图像
要比较的filesystems.php配置:
“验证码”=>[
“驱动程序”=>“本地”,
'root'=>存储路径('app/public/captcha'),
'url'=>env('APP_url')。/storage/captcha/',
“可见性”=>“公共”,
],
“图像”=>[
“驱动程序”=>“本地”,
'root'=>存储路径('app/public/images'),
'url'=>env('APP_url')。/storage/images/',
“可见性”=>“公共”,
],
存储权限设置为777存储:还设置了链接
.htaccess:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
选项-多视图-索引
重新启动发动机
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]
这只发生在共享主机上,所以我想这是与.htaccess有关的。当您使用共享主机时,使用
公共路径而不是存储路径
“验证码”=>[
“驱动程序”=>“本地”,
'root'=>public_path()。/captcha',
'url'=>env('APP_url')。/captcha',
“可见性”=>“公共”,
],
“图像”=>[
“驱动程序”=>“本地”,
“根”=>public_path()。/images',
'url'=>env('APP_url')。/images',
“可见性”=>“公共”,
],
并且只给出文件夹名
它对我有用,你可以试试。如果你使用共享主机,那么就使用公共路径
'images' => [
'driver' => 'local',
'root' => public_path() . '/Any folder name of image',
'url' => env('APP_URL').'/storage/images/',
'visibility' => 'public',
],
解决方案是从公共目录中删除存储目录,然后再次执行storage:link命令。这不是有效的解决方案。根路径与存储路径很好。存储:链接创建laravel存储路径的符号链接,这在某些共享主机提供商中是不可能的。如果您能够做到这一点,请尝试不同的解决方案。您可以发布屏幕截图吗?