Level 104
You missed the encoding type for your form: multipart/form-data is required to upload a file through the form.
<form method="POST" action="{{ route('storemyfile') }}" enctype="multipart/form-data">
I'm trying to setup the file upload procedure locally on my Windows PC.
This is the code in my view:
<form method="POST" action="{{ route('storemyfile') }}">
{{ csrf_field() }}
<input type="text" name="name">
<input type="file" name="myfile" />
<button type="submit">Save</button>
</form>
And this is the code in my Controller:
public function storeMyFile(Request $request)
{
if ($request->hasFile('myfile'))
{
return "HAS FILE.";
}
return "NO FILE.";
}
When I get to the page and choose the file to upload I keep getting "NO FILE." as an answer.
What did I miss ?
Thanks
You missed the encoding type for your form: multipart/form-data is required to upload a file through the form.
<form method="POST" action="{{ route('storemyfile') }}" enctype="multipart/form-data">
Please or to participate in this conversation.