このコミットが含まれているのは:
守矢諏訪子 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) {
if (substr($v, -5) == '.jpeg' || substr($v, -4) == '.jpg' || substr($v, -4) == '.png' || substr($v, -4) == '.gif') {
if (
substr($v, -5) == '.jpeg' && // jpeg
substr($v, -4) == '.jpg' && // jpg
substr($v, -4) == '.png' && // png
substr($v, -4) == '.gif' // gif
substr($v, -5) != '.jpeg' && // jpeg
substr($v, -4) != '.jpg' && // jpg
substr($v, -4) != '.png' && // png
substr($v, -4) != '.gif' // gif
) {
$ok = false;
}
@ -112,26 +112,40 @@ class MeetingsController extends Controller {
try {
if (isset($r->pdf)) {
$filename = uniqid() . '.pdf';
$pdf = base64_decode(substr($r->pdf, strpos($r->pdf, ',') + 1));
$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);
foreach ($r->image as $img) {
if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') {
$ext = explode('/', mime_content_type($img))[1];
$filename = uniqid() . '.'.$ext;
$image = base64_decode(substr($img, strpos($img, ',') + 1));
Storage::disk('public')->put($filename, $image);
if (isset($r->image)) {
foreach ($r->image as $img) {
if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') {
$ext = explode('/', mime_content_type($img))[1];
$fname = uniqid() . '.'.$ext;
$image = base64_decode(substr($img, strpos($img, ',') + 1));
Storage::disk('public')->put($fname, $image);
$filename = '/storage/'.$fname;
}
else {
$filename = $img;
}
$insert_image = [
'meeting_id' => (int)$meeting->id,
'image' => '/storage/'.$filename,
'image' => $filename,
];
MeetingImage::create($insert_image);
}
}