Photoshop MIME type not working???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Photoshop MIME type not working???

Post by seodevhead »

Hey guys... I have a contact form that allows users to upload files to me, and of those allowed file types, I want them to be able to send me .psd (photoshop) files. I have scoured the internet finding every possible mime-type for photoshop files, however, it is still not allowing upload of .psd files. (everything else works perfectly).

Below is a piece of my offending code:

Code: Select all

$allowed = array ('image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/pjpeg', 'text/plain', 'application/postscript', 'image/bmp', 'image/x-windows-bmp', 'application/msword', 'application/pdf', 'image/tiff', 'application/excel', 'application/x-excel', 'application/x-msexcel', 'application/x-compressed', 'application/x-zip-compressed', 'application/zip', 'multipart/x-zip', 'video/quicktime', 'video/x-ms-wmv', 'image/x-photoshop', 'text/rtf', 'image/photoshop', 'image/x-photoshop', 'image/psd', 'application/photoshop', 'application/psd', 'zz-application/zz-winassoc-psd');
					if (!in_array($_FILES[$filename]['type'], $allowed))
					{
						$upload_valid = FALSE;
						$errors[] = 'This file type is not allowed for upload through this form.';
						unlink ($_FILES[$filename]['tmp_name']);
						
					}
Thanks for any help.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Likely, it's coming in under octet-stream.
User avatar
seodevhead
Forum Regular
Posts: 705
Joined: Sat Oct 08, 2005 8:18 pm
Location: Windermere, FL

Post by seodevhead »

Hey feyd,

You are right, it is coming in under 'application/octet-stream'.

However, my conditional is still failing. (producing the error).

I have updated my list to add-in 'application/octet-stream' but still no luck. Any idea what could be causing this? There are no other extraneous problems to speak of such as filesize, mem limits, etc.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Honestly, you should not even be using the supplied type information as it is entirely controlled by the submitting agent.

Use something like mime_content_type() or the other similar functions available to analyze the file itself.
Post Reply