Skip to content

Instantly share code, notes, and snippets.

@yamin27
Last active February 24, 2018 06:33
Show Gist options
  • Save yamin27/3566cd4fe605adb27d55f74819d5fa1d to your computer and use it in GitHub Desktop.
Save yamin27/3566cd4fe605adb27d55f74819d5fa1d to your computer and use it in GitHub Desktop.
#File Upload
if (!empty($request->file('files'))) {
if (!file_exists(public_path() . '/files')) {
mkdir(public_path() . '/files', 0777, true);
}
foreach ($request->file('files') as $file) {
$ext = strtolower($file->getClientOriginalExtension());
$fileFullName = 'meetings '. $meetings->time . '.' . $ext;
$file->move(
public_path() . '/files/', $fileFullName
);
}
$meetings->files()->create([
'url' => $fileFullName,
'mimes' => $file->getClientMimeType(),
]);
}
#blade File
<form action="{{url('meetings')}}" method="post" class="form-horizontal" enctype="multipart/form-data">
<div class="form-group">
<label class="control-label col-md-3">Meeting File</label>
<div class="col-md-9">
<input type="file" class="form-control" name="files[]" value="{{old('files[]')}}">
</div>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment