首页 > 解决方案 > 无法猜测 MIME 类型,因为没有可用的猜测器(您是否启用了 php_fileinfo 扩展?)

问题描述

我正在使用 laravel 6,但我不断收到此错误

Unable to guess the MIME type as no guessers are available (have you enable the php_fileinfo extension?).

我的控制器:

public function profileData(Request $request)
{
    $validate = $request->validate([
        $request->file('bannerFile') => 'required',
        $request->file('profileFile') => 'required',
        $request->input('name') => 'required',
        $request->input('bio') => 'required',
        $request->input('addr') => 'required',
        $request->input('hbd') => 'required',
    ]);
    $bfile = $request->file('bannerFile');
    $pfile = $request->file('profileFile');

    $nme = $request->input('name');
    $bio = $request->input('bio');
    $addr = $request->input('addr');
    $bd = $request->input('hbd');

    $add = Follower::where('user_id',session('id'))->updateOrCreate([
        'user_id' => Auth::user()->id,
        ],[
        "bio" => $bio,
        "image" => $pcontents,
        "banner" => $bcontents,
        "birthday" => $hbd,
        "address" => $addr,
    ]);
    if ($add) {

        return url()->previous();

    }

}

我的刀片:

    <div class="modal fade" id="exampleModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable" style="overflow-x: hidden;">
    <div class="modal-content">
      <div class="modal-body">
        <div class="row">
            <form id="picSubmit" action="{{ route('profileInfo') }}" method="POST" enctype="multipart/form-data">
            @csrf            
              <label>
                 <img src="/imgs/camera.svg" style="
                  cursor: pointer;
                  position: absolute;
                  top: 33%;
                  z-index: 100;
                  left: 15%;
                  transform: translate(-50%, -50%);
                ">
               <div>
               <img src="/imgs/bg.jpg" style="cursor: pointer;object-fit: cover;width: 495px;height:200px; filter: grayscale(40%);">
                 
               </div>
                <input type="file" name="bannerFile" class="d-none" style="display: none">
              </label>
            
              <label>
                <img src="/imgs/camera.svg" style="
                cursor: pointer;
                position: absolute;
                  top: 20%;
                  left: 50%;
                  transform: translate(-50%, -50%);
                ">
               <div>
               <img src="/imgs/avatar-default.png" class="rounded-circle " style="filter: grayscale(40%);cursor: pointer;object-fit: cover;width: 100%;height:150px;border:5px solid white;position: relative;bottom: 100px;">
               </div>
                <input type="file" name="profileFile" class="d-none" style="display: none">
              </label>
              <div class="UserDetails container" >
                <label>Name</label>
                <input type="text" value="{{$data->name}}" class="form-control" placeholder="Name" name="name">
                <br>
                <label>Bio</label>
                <textarea class="form-control" placeholder="Write Bio" name="bio"></textarea>
                <br>
                <label>Location</label>
                <input type="text" class="form-control" placeholder="Location" name="addr">
                <br>
                <label>Birthday</label>
                <input type="date" class="form-control" name="hbd">
              </div>
            </form>
          </div>

         
      </div>
      <div class="modal-footer">
        <button type="button"  class="btn btn-secondary" data-dismiss="modal">Close</button>
        <button type="button" onclick="document.getElementById('picSubmit').submit()" class="btn btn-primary">Save</button>
      </div>
    </div>
  </div>
</div>

我检查了我的 php ini 文件,它位于 xampp/php/php.ini 中,它只是我的整个 xampp 文件夹中的 php.ini 文件,我搜索了 php_fileinfo.dll 不存在,但有 fileinfo 扩展名未注释我'我在这个错误上工作了一天,仍然无法得到答案

谢谢

标签: phplaravelformslaravel-5php-ini

解决方案


推荐阅读