Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP : binary image data, checking the image type

Tags:

php

image

I have some images in bin, I want to check the header to check the format (jpg, png, etc)

I don't want to use temp files! I have a solution using TEMP FILES.

like image 436
llazzaro Avatar asked Jul 22 '10 19:07

llazzaro


1 Answers

I can see that most of you didn't understand the question :) (question was how to validate binary data in buffer, not a file on disk).

I had same problem, and resolved it with:

$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->buffer($rawImage);
like image 61
Marcin Hubert Avatar answered Sep 16 '22 16:09

Marcin Hubert