Skip to content

Instantly share code, notes, and snippets.

@osbre
Created September 2, 2018 16:04
Show Gist options
  • Save osbre/60d1f30093a244506cd34c5b3622d49e to your computer and use it in GitHub Desktop.
Save osbre/60d1f30093a244506cd34c5b3622d49e to your computer and use it in GitHub Desktop.
<?php
if ($request->hasFile('photos')) {
$allowedFileExtension = ['jpeg', 'jpg', 'png'];
$files = $request->file('photos');
foreach ($files as $file) {
$extension = $file->getClientOriginalExtension();
$check = in_array($extension, $allowedFileExtension);
if ($check) {
$filename = $file->store('public/photos');
$this->photos()->create([
'filename' => $filename
]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment