Enabled fileinfo but still getting an error WordPress plugin requiement

懵懂的女人 提交于 2020-01-16 10:34:27

问题


Recently I uploaded my file on live server and facing this error shown below but everything is working good on my local server.

Fatal error: Class 'finfo' not found in plugins/doc management/view/add_doc.php on line 71 The site is experiencing technical difficulties. Please check your site admin email inbox for instructions.

Code

$file = file_get_contents($url);
$filesize = strlen($file);
$file_info = new finfo(FILEINFO_MIME_TYPE);
$mime_type = $file_info->buffer(file_get_contents($file));
if(in_array($extension, $allowedExts)){ 
chmod(ABSPATH.'/wp-content/uploads/2019/07/',0777);
$upload = file_put_contents(ABSPATH.'/wp-content/uploads/2019/07/'.$name,$file);

What I have tried so far to get rid of this error.

tried to enabled fileinfo via .htaccess file but getting 500 internal server error page is not working after doing that. I tried to add them in the end of the .htaccess file

php_value extension=php_fileinfo.dll

or

php_admin_flag extension=php_fileinfo.dll

Solution2: I tried to add ini_set('extension', 'php_fileinfo.so'); to enable fileinfo but stil getting the same error after adding it.

solution 3: I tried to create a php.ini file in the root folder of the public HTML page to override the php.ini file with mine but it still won't work out getting the same error.

my WordPress site is inside a subfolder of the public_html directory. there is html index.html page on the root as a landing page.

I don't know how to check that it is enabled or not. I create info.php file and added phpinfo() function to see the PHP details it is showing but I don't know what finfo is there how to find it. tried to search out but won't work.

I am having Cpanel access tried but not working out. the ways I tried and I am having PHP 5.6 which is greater than PHP 5.3

I checked out phpinfo(); and in configuration, it is showing...

--enable-fileinfo=shared'

but still, I am getting the same error.

on my localhost when I use phpinfo() it shows that fileinfo is enabled. but on the server phpinfo() is not showing that fileinfo is availabe.


回答1:


for these reasons only I have stopped using plugins, If u will code from urself, u won't have any issue in any environment.

try to deactivate your plugins one by one and check, which plugin is causing the issue, if it's possible check another plugin with same features, or can make your own (best way).

Some of your plugin requires finfo (fileinfo)- is an optional php extension. You can enable it through CPanel or in php.ini, depending on your hosting.

If you are using dedicated hosting, u can edit it by yourself; if not, call your hosting provider.



来源:https://stackoverflow.com/questions/57141795/enabled-fileinfo-but-still-getting-an-error-wordpress-plugin-requiement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!