Image Laravel图片上传失败

Image Laravel图片上传失败,image,upload,laravel-5.4,Image,Upload,Laravel 5.4,我正在开发Laravel 5.4应用程序,我试图上传的图片没有移动到我的磁盘上。 你能帮我吗 我的表格: <form class="form-horizontal" role="form" method="POST" action="{{ route('adminPostNews') }}" accept-charset="UTF-8" enctype="multipart/form-data"> {{ csrf_field() }} &l

我正在开发Laravel 5.4应用程序,我试图上传的图片没有移动到我的磁盘上。 你能帮我吗

我的表格:

<form class="form-horizontal" role="form" method="POST" action="{{ route('adminPostNews') }}" accept-charset="UTF-8" enctype="multipart/form-data">

          {{ csrf_field() }}

          <div class="form-group{{ $errors->has('picture') ? ' has-error' : '' }}">
              <label for="picture" class="col-md-1 control-label">Photo</label>

              <div class="col-md-6">
                <input type="file" id="picture" name="picture">

                  @if ($errors->has('picture'))
                      <span class="help-block">
                          <strong>{{ $errors->first('picture') }}</strong>
                      </span>
                  @endif
              </div>
          </div>

          <div class="form-group">
              <div class="col-md-6 col-md-offset-4">
                  <button type="submit" class="btn btn-primary">
                      Ajouter
                  </button>
              </div>
          </div>
      </form>

我的磁盘正常,Laravel给出了文件名,但上传不起作用。

好的,也许第一个答案是:服务器文件上传大小限制! 其次,这是我的新代码:

$file = $request->file('picture');
    $extension = $file->getClientOriginalExtension();
    Storage::disk('news')->put($file->getFilename().'.'.$extension,  file_get_contents($file));

我未能使用与“文件获取内容”不同的内容。

好的,也许第一个答案是:服务器文件上载大小限制! 其次,这是我的新代码:

$file = $request->file('picture');
    $extension = $file->getClientOriginalExtension();
    Storage::disk('news')->put($file->getFilename().'.'.$extension,  file_get_contents($file));

我未能使用与“文件获取内容”不同的内容。

如果传递的文件名不正确,请尝试以下操作:

//Save image
if ($request->hasFile('picture')) {
    $file = $request->file('picture');
    $fileName = $file->getClientOriginalName();
    Storage::disk('news')->put($fileName, File::get($file));
}

您没有正确传递文件名,请尝试以下操作:

//Save image
if ($request->hasFile('picture')) {
    $file = $request->file('picture');
    $fileName = $file->getClientOriginalName();
    Storage::disk('news')->put($fileName, File::get($file));
}