I'm trying to make a form to upload a file, an excel file, this is my html
<h2>Agregar Torneo</h2>
{{Form::open('admin/addtorneo', 'POST',array('files' => 'true', 'enctype' => "multipart/form-data"))}}
{{Form::label('cvs', 'Archivo:')}}
{{Form::file('cvs')}}
{{Form::submit('Subir')}}
{{Form::close()}}
and the php
$file = Input::file('cvs');
$destinationPath = 'uploads/'.Str::random(5);
$filename = Input::file('cvs.name');
$uploadSuccess = Input::file('cvs')->move($destinationPath, $filename);
$new = new Torneo;
$new->nombre = $filename;
$new->dir = $destinationPath;
$new->save();
return "Torneo agregado <br> <a href='../admin'>Volver</a>";
but I keep getting
Call to a member function move() on a non-object
I tried using $file->getClientOriginalName() instead of Input::file('cvs.name') but I get Call to a member function getClientOriginalName() on a non-object, It seems to me that the form isn't right and it ain't reciving the file correctly
Just call Input::file('cvs') one time, the second time it becomes null object.
example :
$file = Input::file('cvs');
$destinationPath = 'uploads/'.Str::random(5);
$file->move($destinationPath);
It works.