hasFile('qrcode')){ $path = $request->file('qrcode')->store('qrcodes'); $qrcode = new QrReader(storage_path('app/' . $path)); $uri = urldecode($qrcode->text()); $uriChunks = explode('?', $uri); foreach(explode('&', $uriChunks[1]) as $option) { $option = explode('=', $option); $options[$option[0]] = $option[1]; } $account = $service = ''; $serviceChunks = explode(':', str_replace('otpauth://totp/', '', $uriChunks[0])); if( count($serviceChunks) > 1 ) { $account = $serviceChunks[1]; } $service = $serviceChunks[0]; if( strstr( $service, '@') ) { $account = $service; $service = ''; } if( empty($service) & !empty($options['issuer']) ) { $service = $options['issuer']; } $twofaccount = (object) array( 'service' => $service, 'account' => $account, 'uri' => $uri, 'icon' => '', 'options' => $options ); Storage::delete($path); return response()->json($twofaccount, 201); } else { return response()->json('no file in $request', 204); } } }