[英]Fatal error: Class 'finfo' not found in C:\xampp\htdocs\portfolio\actions\addProject_action.php on line 49
I'm trying to do a fileupload on my website. 我正在尝试在我的网站上进行文件上传。 And I checked in the PHP manual and found this for checking the filetype: 然后,我检查了PHP手册,发现该文件用于检查文件类型:
// DO NOT TRUST $_FILES['upfile']['mime'] VALUE !!
// Check MIME Type by yourself.
$finfo = new finfo(FILEINFO_MIME_TYPE); // line 49
if (false === $ext = array_search(
$finfo->file($_FILES['topImage']['tmp_name']),
array(
'jpg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif',
),
true
)) {
throw new RuntimeException('Invalid file format.');
}
But with this code I get an php error that says: Fatal error: Class 'finfo' not found in C:\\xampp\\htdocs\\portfolio\\actions\\addProject_action.php on line 49 但是通过此代码,我得到了一个PHP错误,指出:致命错误:在49行的C:\\ xampp \\ htdocs \\ portfolio \\ actions \\ addProject_action.php中找不到类“ finfo”
Anyone that know why and how to fix this? 有谁知道为什么以及如何解决这个问题? (apparently I have the wrong PHP version 5.2.0, so I would more like to know if there is a similar good way to do this in erlier PHP versions?) (显然我的PHP版本是5.2.0,所以我想知道在错误的PHP版本中是否有类似的好方法?)
I have this code inside this: 我里面有这段代码:
if(empty($_FILES['topImage'])){
$errors['topImage'] = "You have to choose a Top Image.";
}else{
// The code is inside here
}
i think finfo class is available in PHP >= 5.3.0. 我认为finfo类在PHP> = 5.3.0中可用。 maybe your PHP is lower 5.3.0. 也许您的PHP低于5.3.0。
取消注释\\ xampp \\ php \\ php.ini文件中的;extension=php_fileinfo.dll
行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.