このコミットが含まれているのは:
守矢諏訪子 2021-11-18 00:31:39 +09:00
コミット 97c3d35f70
1個のファイルの変更30行の追加16行の削除

ファイルの表示

@ -49,10 +49,10 @@ class MeetingsController extends Controller {
foreach (json_decode($value) as $v) { foreach (json_decode($value) as $v) {
if (substr($v, -5) == '.jpeg' || substr($v, -4) == '.jpg' || substr($v, -4) == '.png' || substr($v, -4) == '.gif') { if (substr($v, -5) == '.jpeg' || substr($v, -4) == '.jpg' || substr($v, -4) == '.png' || substr($v, -4) == '.gif') {
if ( if (
substr($v, -5) == '.jpeg' && // jpeg substr($v, -5) != '.jpeg' && // jpeg
substr($v, -4) == '.jpg' && // jpg substr($v, -4) != '.jpg' && // jpg
substr($v, -4) == '.png' && // png substr($v, -4) != '.png' && // png
substr($v, -4) == '.gif' // gif substr($v, -4) != '.gif' // gif
) { ) {
$ok = false; $ok = false;
} }
@ -112,24 +112,38 @@ class MeetingsController extends Controller {
try { try {
if (isset($r->pdf)) { if (isset($r->pdf)) {
$filename = uniqid() . '.pdf'; $filename = uniqid() . '.pdf';
$pdf = base64_decode(substr($r->pdf, strpos($r->pdf, ',') + 1));
$insert['pdf'] = '/storage/'.$filename; $insert['pdf'] = '/storage/'.$filename;
Storage::disk('public')->put($filename, $pdf);
if (substr($r->pdf, -4) != '.pdf') {
$pdf = base64_decode(substr($r->pdf, strpos($r->pdf, ',') + 1));
Storage::disk('public')->put($filename, $pdf);
}
else {
$insert['pdf'] = $r->pdf;
}
} }
$meeting = Meeting::create($insert); $meeting = Meeting::create($insert);
foreach ($r->image as $img) { if (isset($r->image)) {
if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') { foreach ($r->image as $img) {
$ext = explode('/', mime_content_type($img))[1]; if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') {
$filename = uniqid() . '.'.$ext; $ext = explode('/', mime_content_type($img))[1];
$image = base64_decode(substr($img, strpos($img, ',') + 1)); $fname = uniqid() . '.'.$ext;
Storage::disk('public')->put($filename, $image); $image = base64_decode(substr($img, strpos($img, ',') + 1));
Storage::disk('public')->put($fname, $image);
$filename = '/storage/'.$fname;
}
else {
$filename = $img;
}
$insert_image = [ $insert_image = [
'meeting_id' => (int)$meeting->id, 'meeting_id' => (int)$meeting->id,
'image' => '/storage/'.$filename, 'image' => $filename,
]; ];
MeetingImage::create($insert_image); MeetingImage::create($insert_image);