Laravel Upload自动将jpg转换为jpeg

时间:2018-10-28 18:26:04

标签: laravel

我正在尝试上传图片。上传效果很好,但是当我尝试上传jpg图片时,它将自动转换为jpeg。这是我的代码

if($request->hasFile('image'))
        {
            if($request->file('image')->store('public/gallery'))
            {
                $gallery = new Gallery();
                $gallery->album_id = $request->album;
                $gallery->photo = $request->image->hashName();
                $gallery->save();
                Session::flash('message','Success:: Image added to gallery');
                Session::flash('alert','alert alert-success alert-dismissable');
                return back();
            }
            else
            {
                Session::flash('message','Warning:: Failed to upload the image');
                Session::flash('alert','alert alert-warning alert-dismissable');
                return back()->withInput();
            }
        }

我真的在寻求帮助,谢谢

1 个答案:

答案 0 :(得分:0)

Laravel通过检查文件的MIME类型自动确定文件的扩展名。 jpg和jpeg之间确实没有区别。参见JPG vs. JPEG image formats