Php laravel 4上传文件
我正在制作一个表格来上传一个文件,一个excel文件, 这是我的htmlPhp laravel 4上传文件,php,upload,laravel,laravel-4,Php,Upload,Laravel,Laravel 4,我正在制作一个表格来上传一个文件,一个excel文件, 这是我的html <h2>Agregar Torneo</h2> {{Form::open('admin/addtorneo', 'POST',array('files' => 'true', 'enctype' => "multipart/form-data"))}} {{Form::label('cvs', 'Archivo:')}} {{Form::file('cvs')}}
<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()}}
我尝试使用$file->getClientOriginalName()代替Input::file('cvs.name'),但我在非对象上调用了一个成员函数getClientOriginalName(),在我看来,表单不正确,无法正确接收文件只需调用Input::file('cvs'),第二次它变为null对象
例如:
$file = Input::file('cvs');
$destinationPath = 'uploads/'.Str::random(5);
$file->move($destinationPath);
它可以工作。看起来没有生成$filename。将$filename更改为类似“testname”(不使用变量)的内容,然后查看是否可以解决此问题。本质上,它看起来像$filename='test';如果这样做有效,那么将filename改为:$filename=$file['name'];我不断收到对非对象上的成员函数move()的调用:/当您在html中查看表单时,您看到了什么?也许您没有设置“名称”,只是设置了id。
Call to a member function move() on a non-object
$file = Input::file('cvs');
$destinationPath = 'uploads/'.Str::random(5);
$file->move($destinationPath);