簡體   English   中英

Laravel 流明圖像驗證不起作用

[英]Laravel Lumen image validation is not working

我正在將請求驗證為圖像,但崩潰說:

“無法猜測 MIME 類型,因為沒有可用的猜測器(您是否啟用了 php_fileinfo 擴展?)”。

php.ini ,我沒有extension=php_fileinfo ,但我確實有一個extension=fileinfo未注釋的行(我看到 Lumen 放置了這個和其他沒有'php_'依賴項)。 我也嘗試添加extension=php_fileinfo ,但是當我從 XAMPP 重新啟動 Apache 時,它會崩潰,因為它沒有找到該依賴項。 我應該怎么辦?

編碼:

function updateProfilePicture(Request $request) {
    $this->validate($request, [
        'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
    ]);
//...

php.ini 部分,其中 fileinfo 依賴項是:

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; If you wish to have an extension loaded automatically, use the following
; syntax:
;
;   extension=modulename
;
; For example:
;
;   extension=mysqli
;
; When the extension library to load is not located in the default extension
; directory, You may specify an absolute path to the library file:
;
;   extension=/path/to/extension/mysqli.so
;
; Note : The syntax used in previous PHP versions ('extension=<ext>.so' and
; 'extension='php_<ext>.dll') is supported for legacy reasons and may be
; deprecated in a future PHP major version. So, when it is possible, please
; move to the new ('extension=<ext>) syntax.
;
; Notes for Windows environments :
;
; - Many DLL files are located in the extensions/ (PHP 4) or ext/ (PHP 5+)
;   extension folders as well as the separate PECL DLL download (PHP 5+).
;   Be sure to appropriately set the extension_dir directive.
;
extension=bz2
extension=curl
extension=fileinfo
extension=gd2
extension=gettext

也許它與關於如何設置依賴項指令的免責聲明有關? (我不確定,因為extension=fileinfo作為默認值已經在文件中)我正在使用 windows 10,我在C:\xampp\php\ext\php_fileinfo.dll中找到了該文件

我發現了問題。 我有另一個 php.ini 文件,其中注釋行;extension=fileinfoC:\php\php.ini中(我打開的那個是C:\xampp\php\php.ini 現在我重新啟動了 Apache 並且它正在工作!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM