Last active
January 13, 2020 14:55
-
-
Save paulodutra/7e82c10574abac3c09406450926bc198 to your computer and use it in GitHub Desktop.
Definindo o método sendFile e também o formato de recebedimento da requisição de upload de arquivos base64 utilizando o laravel
This file contains hidden or 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
<?php | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use Illuminate\Support\Facades\Storage; | |
class UploadController extends Controller | |
{ | |
/** | |
* sendFile: Método responsável por enviar o arquivo no formato base64 | |
*/ | |
public function sendFile(Request $request) | |
{ | |
if($request->has('file') && strpos($request->file, ';base64')){ | |
$base64 = $request->file; | |
dd($base64) | |
}else{ | |
return response() | |
->json(['message' => 'Envie o atributo file no formato base64'], 422); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment