Get PHP BLOB type

Asked

Viewed 51 times

0

Next, I need to know the type of BLOB I am getting through my select, so I can set up a suitable header("Content-Type"), ie if my file is PDF, set header content as pdf, and so on.... I didn’t find any solution similar, but follow my doubt:

$sql = "select notaf_manutencao from manutencao_caminhao where id_manutencao = '$id'";
$exe = $conn->query($sql)
$pdf = mysqli_fetch_object($exe);; //Quero obter apenas o tipo de arquivo que veio.

I didn’t want to use a flag in my bank to know the type, can I get it directly from mysqli_fetch_object? Thank you.

  • Maybe something like this? https://www.php.net/manual/en/function.mime-content-type.php

  • 1

    But I still think the most recommended is to have the file type saved in a column in the database

  • That’s right, perfect!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.