Dropzone显示上传成功,但在Laravel 5中文件没有上传


Dropzone shows upload success but file is not uploaded in Laravel 5

我仍然在学习Laravel,并试图建立某种文章管理系统。作为插入新文章的形式的一部分,我也想上传他们的多张照片。上传显示成功,但上传文件夹中没有文件。下面是我的表单代码:

{!! Form::open(['route' => 'admin_artikli.store', 'class' => 'dropzone', 'id' => 'create_artikal', 'enctype' => 'multipart/form-data' ]) !!}
    <div class="form-group">
        {!! Form::label('Firma', 'Firma') !!}
        {!! Form::text('firma_id', Input::old('firma_id'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Naziv', 'Naziv') !!}
        {!! Form::text('naziv', Input::old('naziv'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Opis', 'Opis') !!}
        {!! Form::text('opis', Input::old('opis'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('Cijena', 'Cijena') !!}
        {!! Form::text('cijena', Input::old('cijena'), array('class' => 'form-control')) !!}
    </div>
    <div class="form-group">
        {!! Form::label('kolicina', 'kolicina') !!}
        {!! Form::text('kolicina', Input::old('kolicina'), array('class' => 'form-control')) !!}
    </div>  
        <div class="form-group">
        {!! Form::label('dostupnost', 'dostupnost') !!}
        {!! Form::text('dostupnost', Input::old('dostupnost'), array('class' => 'form-control')) !!}
    </div>  
    <div class="form-group">
       {!! Form::select('aktivan', array('D' => 'Aktivan', 'N' => 'Neaktivan'), 'D')  !!}
    </div>  
    <div class="form-group">
       {!! Form::select('aktivan', array('D' => 'Aktivan', 'N' => 'Neaktivan'), 'D')  !!}
    </div>  
    {!! Form::submit('Kreiraj artikal', array('class' => 'btn btn-primary', 'id' => 'create_artikal_submit')) !!}
{!! Form::close() !!}

My routes.php(只显示相关的):

Route::post('/upload', 'ArtikalAdminController@upload');
Route::resource('admin_artikli', 'ArtikalAdminController');

我的控制器存储和上传方法:

public function upload(){
    $input = Input::all();
    $rules = array(
        'file' => 'image|max:3000'
    );
    echo "eldaaaaaaaaaaaaaaaaaaaaaaaaar";
    $validation = Validator::make($input, $rules);
    if ($validation->fails())
    {
        return Response::make($validation->errors->first(), 400);
    }
    $file = Input::file('file');
    $extension = File::extension($file['name']);
    $directory = public_path().'uploads/'.sha1(time());
    $filename = sha1(time().time()).".{$extension}";
    $file->move($directory, $filename);
    $upload_success = Input::file('file', $directory, $filename)->move($directory, $filename);;
    echo $directory;
    if( $upload_success ) {
        return Response::json('success', 200);
    } else {
        return Response::json('error', 400);
    }
}

 public function store(Request $request)
{
    $artikal = new Artikal;
    $artikal->firma_id       = Input::get('firma_id');
    $artikal->naziv          = Input::get('naziv');
    $artikal->sifra          = Input::get('sifra');
    $artikal->opis           = Input::get('opis');
    $artikal->cijena         = Input::get('cijena');
    $artikal->kolicina       = Input::get('kolicina');
    $artikal->dostupnost     = Input::get('dostupnost');
    $artikal->aktivan        = Input::get('aktivan');
    $artikal->save();
    Session::flash('flash_message', 'Uspješno unesen artikal!');
    //return redirect()->back();
}

最后,我目前使用的dropzone选项:

  Dropzone.options.createArtikal = { // The camelized version of the ID of the form element
  // The configuration we've talked about above
  autoProcessQueue: false,
  uploadMultiple: true,
  parallelUploads: 10,
  maxFiles: 10,
  // The setting up of the dropzone
  init: function() {
    var myDropzone = this;
    // First change the button to actually tell Dropzone to process the queue.
    var element = document.getElementById('create_artikal_submit');
    var form = document.getElementById('create_artikal');
    element.addEventListener("click", function(e) {
      // Make sure that the form isn't actually being sent.
      e.preventDefault();
      e.stopPropagation();
      myDropzone.processQueue();
    });
    // Listen to the sendingmultiple event. In this case, it's the sendingmultiple event instead
    // of the sending event because uploadMultiple is set to true.
    this.on("sendingmultiple", function() {
      // Gets triggered when the form is actually being sent.
      // Hide the success button or the complete form.
    });
    this.on("successmultiple", function(files, response) {
      // Gets triggered when the files have successfully been sent.
      // Redirect user or notify of success.
      form.submit();
    });
    this.on("errormultiple", function(files, response) {
      // Gets triggered when there was an error sending the files.
      // Maybe show form again, and notify user of error
    });
  }
}

我知道这里缺少很多东西,但我试着一步一步地前进,但我被困在这里了。当我检查开发工具的网络选项卡时,我看到XHR请求是200 OK,但是我没有看到文件。

你忘了写'files' => true form, update form &试一试。

{!! Form::open(['route' => 'admin_artikli.store', 'class' => 'dropzone', 'id' => 'create_artikal', 'files'=>true, 'enctype' => 'multipart/form-data' ]) !!}