Last active
February 24, 2018 06:33
-
-
Save yamin27/3566cd4fe605adb27d55f74819d5fa1d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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