I am creating an upload screen which allows the user to upload images in RAW format. There are multiple RAW formats and I have a pre defined list of them.
define ('ALLOWED_FILE_TYPE', array(
"image/jpeg",
"image/jpg",
"image/tif",
"image/png",
"image/bmp",
"image/x-canon-cr2",
"image/x-canon-crw",
"image/x-kodak-dcr",
"image/x-nikon-nef",
"image/x-olympus-orf",
"image/x-sony-arw",
"image/x-adobe-dng",
"image/x-epson-erf",
"image/x-kodak-k25",
"image/x-kodak-kdc",
"image/x-minolta-mrw",
"image/x-pentax-pef",
"image/x-fuji-raf",
"image/x-panasonic-raw",
"image/x-sony-sr2",
"image/x-sony-srf",
"image/x-sigma-x3f"
));
(I found this list on stackoverflow. I have not had a chance to check it's authenticity.)
My script is a standard upload form with a call to a method to check the upload file type. Unfortunately, with RAW files, the file type that comes back is 'application/octet-stream':
array (
'name' => 'DSCF0450.RAF',
'type' => 'application/octet-stream',
'tmp_name' => '/private/var/tmp/phpVFT8BJ',
'error' => 0,
'size' => 50560000,
)
Clearly, the RAW file is not being recognised as an image.
Can anyone tell me why?
Do I have to change the upload form enctype to something other than enctype="multipart/form-data"
?
Can anyone tell me how to get the raw file recognised as an image?
N.B:
Processing the image is not an issue. I am trying to validate the upload.
I have tried using finfo and finfo_file to get a file type (it also returns 'application/octet-stream').
I know I could get the file extension and check against that. I would rather not rely on something that can be easily altered, unless I absolutely have to.
Thanks in advance.