问题描述
我的Laravel应用无法验证上传的图像.它返回此错误消息:
My Laravel app can't validate uploaded images. It returns this error message:
我知道在php.ini上启用php_fileinfo.dll/php_fileinfo.so可以解决此问题.但是我无权访问我的远程服务器的php.ini文件.
I know enabling php_fileinfo.dll/php_fileinfo.so at php.ini fixes it. But I don't have access to my remote server's php.ini file.
所以我认为还有其他方法可以启用它吗?如何?也许我可以使用PHP的ini_set()
方法?我尝试像这样使用它:
So I thought is there any other way to enable it? And how? Maybe I can use PHP's ini_set()
methods? I tried using it like:
ini_set('extension', 'php_fileinfo.so');
但这是行不通的.
我还读到您可以使用.htaccess文件覆盖php.ini设置.但是如何?
I also read you can override php.ini settings using .htaccess files. But how?
作为Laravel的默认设置,我的.htaccess文件为:
As Laravel's default, my .htaccess file is:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
您应该如何在其中放置这些额外物品?
How should you put such additionals in there?
推荐答案
在目录的根文件夹中创建自己的php.ini
文件.
create own php.ini
file in root folder of your directory.
例如,如果要在服务器上进行更改,则它应位于public.html文件夹中.
example if you are making changes on a server then it should be inside the public.html folder.
创建文件名php.ini,它将覆盖设置.只需添加文件
create file name php.ini it will override the settings.just add in the file
extension=php_fileinfo.dll
这篇关于如何在PHP中启用php_fileinfo扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!