@ryanborum Well, as the error message suggests, is the php_fileinfo extension enabled?
Two File Uploads Within a Form
Hey all, I have a simple form written to accept a date and two files and store them in a database. The database has fields for an id, a date, two filepaths(varchar), and the standard created/updated timestamps. My page follows the basic CRUD model/functions. When I go to submit my form to create a new entry, I get the error: ** Unable to guess the mime type as no guessers are available (Did you enable the php_fileinfo extension?)**
The 'problem' line is : 'agendaPath' => $request->file('agenda')->store('uploads')which should both store the file in a folder called uploads and save the filepath to the "agendaPath" field in the DB.
I have my php_fileinfo extension enabled in my php install, so I'm not sure how to resolve this. My form/view looks like:
<form action="/agendas" method="post" enctype="multipart/form-data">
{{ csrf_field() }}
<div class="form-group">
<label for="meetingDate">Meeting Date</label>
<input type="date" class="form-control" name="meetingDate">
</div>
<div class="form-group">
<label for="agenda">Agenda File</label>
<input type="file" class="form-control" name="agenda">
</div>
<div class="form-group">
<label for="minutes">Minutes File</label>
<input type="file" class="form-control" name="minutes">
</div>
<input type="submit" class="btn btn-primary">
My Route looks like:
Route::resource('/agendas', 'AgendasController');
My Model looks like:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class Agenda extends Model
{
protected $table = 'agendas';
protected $dates = ['date', 'created_at', 'updated_at'];
protected $fillable = ['date' , 'agendaPath', 'minutesPath', 'canceled'];
}
And the function from my controller is:
public function store(Request $request)
{
$request->validate([
'meetingDate' => 'required',
'agenda' => 'required',
'minutes' => 'required'
]);
$agenda = Agenda::create([
'meetingDate' => $request->date,
'agendaPath' => $request->file('agenda')->store('uploads'),
'minutesPath' => $request->file('minutes')->store('uploads')
]);
return redirect('/agendas/'.$agenda->id);
}
I'd appreciate any insight you all have. Thanks!
Please or to participate in this conversation.