在 Windows PHP 5.3.5 中使用 php_fileinfo.dll 和 finfo_open

发布于 2024-10-19 05:38:16 字数 835 浏览 3 评论 0原文

我在使用 PHP 5.3.5 和 PHP 在 Windows Server 2003 上运行的 PHP 脚本中调用 finfo_open 时遇到问题。 IIS 6。调用总是返回致命错误:调用未定义的函数 finfo_open() in...

通过一点阅读,我知道 Windows PHP 安装中默认不包含 fileinfo 功能,尽管我没有尝试让它工作。注释 #3 中的说明: http://www.php.net/manual /en/fileinfo.installation.php 没有帮助,这是我能找到的最官方的解释。网上有很多关于需要 mime_magic dll 的信息,但从 5.3 开始似乎不再需要它。此外,我在 http://pecl.php.net/package/Fileinfo 上读到“从 PHP 5.3.0 开始,此扩展默认启用”。这是怎么回事?

此问题出现在测试服务器上。在我的本地计算机上,我有 xampp 和 PHP 5.3.1 并且调用工作正常,因此我还尝试在测试时将 php_fileinfo.dll 从本地复制到 php\ext,但这也没有任何区别(我知道版本是不同,但我读到 5.3 是重要的一点)。

任何对此的建议将不胜感激!

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = finfo_file($finfo, $filepath);

I'm having trouble calling finfo_open in a PHP script running on Windows Server 2003 with PHP 5.3.5 & IIS 6. The call always returns Fatal error: Call to undefined function finfo_open() in...

Through a little reading I know that fileinfo functionality is not included by default in the windows PHP installation, though nothing I try gets it working. The instructions in comment #3 here: http://www.php.net/manual/en/fileinfo.installation.php didn't help, and that's the most official looking explanation I can find. There's lots of information about needing the mime_magic dll on the web but it seems like this is no longer required as of 5.3. Furthermore, I have read on http://pecl.php.net/package/Fileinfo that "As of PHP 5.3.0 this extension is enabled by default". What's going on?

This issue is on a testing server. On my local machine I have xampp and PHP 5.3.1 and the call works fine, so I also tried copying the php_fileinfo.dll from local to php\ext on testing but this also didn't make any difference (I know that versions are different, but I read that the 5.3 is the important bit).

Any advice on this would be much appreciated!

    $finfo = finfo_open(FILEINFO_MIME_TYPE);
    $mime = finfo_file($finfo, $filepath);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我不在是我 2024-10-26 05:38:16

您已经接近完成它,只缺少一些小配置。

请参阅fileinfo 使用和安装说明

Windows 用户必须在 php.ini 中包含捆绑的 php_fileinfo.dll DLL 文件才能启用此扩展。

例如,该 DLL 文件与 PHP 5.3.6 捆绑在一起,您可以在此处找到这些文件: PHP For Windows - Binaries and来源发布。它应该已经位于 PHP 安装的 ext 子目录中。如果没有,请从上述网站重新下载(选择您的 PHP 版本)并将其放入扩展目录中。

您需要将以下行添加到 php.ini 然后激活它:

extension=php_fileinfo.dll

这是在 Windows 下激活 PHP 扩展的标准过程。您可以在此处找到有关如何激活 PHP 扩展的更多信息:在 Windows 上安装扩展。如果您无法找到 php.ini 文件,请参阅 PHP 安装说明- 在 Windows 系统上安装

You're already close to get it done, only some little configuration is missing on your end.

Please see the fileinfo usage and installation instructions:

Windows users must include the bundled php_fileinfo.dll DLL file in php.ini to enable this extension.

That DLL file is bundeled with PHP 5.3.6 for example, you can find the files here: PHP For Windows - Binaries and sources Releases. It should be already located in the ext subdirectory of your PHP installation. If not download it again from the said website (choose your PHP version) and place it into the extension directory.

You need to add the following line your php.ini then to activate it:

extension=php_fileinfo.dll

That's the standard procedure to activate a PHP extension under windows. You can find more information about how to actiave a PHP extension here: Installation of extensions on Windows. If you have problems to locate the php.ini file, please refer to the PHP installation instructions - Installation on Windows systems.

も让我眼熟你 2024-10-26 05:38:16

这行代码

extension=php_fileinfo.dll 

在我的 php.ini 中被注释掉了,所以我取消了它的注释,然后重新启动了我的 xampp 服务器。

This line

extension=php_fileinfo.dll 

was commented in my php.ini so I uncommented it and then restarted my xampp server.

百变从容 2024-10-26 05:38:16

在按照 hakre 的建议进行操作后,FileInfo 扩展在我这边仍然没有加载,但最终我发现我正在修改的 php.ini 文件是错误的(位于 \MAMP\bin\php ),从而解决了这个问题\php7.2.10),而正确的位置位于 \MAMP\conf\php7.2.10。
在正确的 ini 文件中启用它后,我必须重新启动 php 服务器,然后它就可以工作了。

注意:您可能需要将路径开头的“\MAMP”替换为安装 Web 服务器解决方案堆栈软件(例如 MAMP、WAMP、XAMP 或其他)的路径。由于我使用的是 MAMP,这就是它出现在我的文件路径中的原因

After doing what hakre suggested, the FileInfo extension was still not loaded at my end, but then eventually I solved it by figuring out that the php.ini file I was modifying was the wrong one (that was located at \MAMP\bin\php\php7.2.10) whereas the correct one was located at \MAMP\conf\php7.2.10.
After enabling it in the correct ini file, I had to restart the php server and off it worked.

NOTE: You might have to replace '\MAMP' from the start of the path with the path where your web-server solution stack software (e.g. MAMP, WAMP, XAMP or else) is installed. Since I was using MAMP that's why its present in my file path

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文