php - File fails to upload in laravel -


here routes file

route::resource('item', 'itemcontroller');  route::get('welcome', function() {     return view('welcome'); }); route::auth();  route::get('/home', 'homecontroller@index'); route::get('/item', 'itemcontroller@store');  //route route::post('/item', ['as' => 'item.store', 'uses' => 'itemcontroller@store']); 

here store controller

public function store(requests\createitem $request) {     item::create($request->all());     $file = $request->file('filename');     if (input::hasfile('filename')) {         echo 'uploaded';         $file = input::file('filename');         $file->move('uploads', $file->getclientoriginalname());     } } 

my upload form not return errors, snippet of code not moving uploads folder specified. doing wrong? using laravel 5.2.

edit: here form

   {!! form::open(['url' =>'route' => 'item.store', 'files' => true]) !!}     {!! form::label('name', "name") !!}     {!! form::text('name', null, ['class' => 'form-control']) !!}     {!! form::label('filename', "file name") !!}     {!! form::file('filename', null, ['class' => 'form-control']) !!}      {!! form::label('description', 'description') !!}     {!! form::textarea('description', null, ['class' => 'form-control']) !!}     {!! form::submit('add item', ['class' => 'btn btn-primary form-control']) !!} 

edit 2: i'm getting following error upon accessing form

fatalerrorexception in 41b177cdb949fd0263185e364012b35dff81db06.php line 7: syntax error, unexpected '=>' (t_double_arrow), expecting ']'

edit 2 error everytime try access add item form:

fatalerrorexception in 41b177cdb949fd0263185e364012b35dff81db06.php line 7: syntax error, unexpected '=>' (t_double_arrow), expecting ']'

does <form> have enctype="multipart/form-data" on it? needs send files properly. it's practically error whenever <form> has <input type="file"> elements in it, doesn't have attribute.

this pretty common mistake, gets people time.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -