Level 41
You put the enctype attribute on the form, not the input.
<form action="/materias" method="post" enctype="multipart/form-data">
I'm trying to make a fileupload but the request is returning null and i don't know why... Can anyone help me?
Here my routes file:
Route::get('/materias', 'MateriasController@index');
Route::get('/materias/novo', 'MateriasController@create');
Route::post('/materias', 'MateriasController@store');
My view file:
<form action="/materias" method="post">
{!! csrf_field() !!}
<div class="form-group">
<label>Nome da matéria:</label>
<input class="form-control" type="text" name="name">
</div>
<div class="form-group">
<label>Imagem banner:</label>
<input type="file" name="file">
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">Criar matéria</button>
</div>
</form>
And my controller:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
/**
* the upload method
*/
public function store(Request $request)
{
if ($request->hasFile('file'))
{
return 'Uploaded';
}
}
Really, any help will be apreciated guys :D
You put the enctype attribute on the form, not the input.
<form action="/materias" method="post" enctype="multipart/form-data">
Please or to participate in this conversation.