detect binary file's mime type
Posted: Sat Aug 20, 2011 12:39 pm
Hi guys,
I have a question, how can detect a binary file's mime type?
I am creating a system API that allows the client to upload files within my server via API calls. The client must send the image into binary like this:
Then comes an image to the server in binary base64-encoded. My server will decode it and save it in a folder.
To decode it, I wrote:
for save the image, i want use "file_put_contents" but first i must detect the mime type of decoded image. How can I do?
Thanks
matt86
I have a question, how can detect a binary file's mime type?
I am creating a system API that allows the client to upload files within my server via API calls. The client must send the image into binary like this:
Code: Select all
function ImgToBinary($pathImg)
{
$con = file_get_contents($pathImg);
$en = base64_encode($con);
return $en;
}
To decode it, I wrote:
Code: Select all
$image = base64_decode($my_binary_image_base64);
Thanks
matt86