Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ChristophAust's avatar

Receiving images with mimetype application/octet-stream

Hi guys,

I have a new challenge. So I am receiving images from a mobile app. On some android devices when it is uploaded from the camera directly, I get the mimetype application/octet-stream.

This mimetype can basically be anything.

I read on stackoverflow that "getimagesize" is a reasonable safe way to determine if the uploaded file is really an image.

But somehow this "feels wrong". Has anyone stumbled upon a similiar issue?

0 likes
7 replies
siangboon's avatar

@ChristophAust perhaps showing the code, expected result, error and debug result will help others to understand your problem better...

ChristophAust's avatar

@siangboon sorry, I guess you are right. So what I am doing is checking an image against the mimetypes jpeg and png. When it is sent from a native app using the camera the mimetype sometimes is application/octet-stream. I do not really feel good with simply adding it to the accepted mimetypes since it can be basically anything.

So I am looking for a way to securely check if it is an image or not.

ChristophAust's avatar

@Sinnbeck good catch! This is considered a safe check whether the file is an image? You know by chance? Otherwise I would dig into the source code and check.

Please or to participate in this conversation.