Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Falha Helper->fileToBase64 #3

Closed
FelipeAugusto26 opened this issue Jul 9, 2023 · 1 comment
Closed

Falha Helper->fileToBase64 #3

FelipeAugusto26 opened this issue Jul 9, 2023 · 1 comment

Comments

@FelipeAugusto26
Copy link

Visto a falha:

Warning: finfo_file(): Failed identify data 0:(null) in php
quando usado para converter a imagem para envio de media

Solução encontrada:
Function exemplo:
/**
* HELPER CONVERT FILE BASE64
* @return string
*/
public function fileToBase64(string $file): string
{
$type = image_type_to_mime_type(exif_imagetype($file));
return 'data:' . $type . ';base64,' . base64_encode(file_get_contents($file));
}

Usando a função image_type_to_mime_type

Abraço!!
@bgastaldi
Copy link
Collaborator

Fixed.
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants