Page 1 of 1

WMV Mime Type Error w/ PHP Upload

Posted: Tue Sep 02, 2008 6:07 pm
by rbc
I'm trying to create a file upload system and want to allow for wmv video files to be uploaded. Below is a piece of the code:

Code: Select all

$allowed = array ('image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg', 'video/quicktime', 'video/x-quicktime', 'video/mpeg', 'video/x-mpeg', 'video/x-msvideo', 'video/mp4', 'video/x-sgi-movie', 'video/x-ms-asf', 'audio/x-ms-wmv', 'video/x-ms-wm', 'video/x-ms-wmx', 'video/x-ms-wmv', 'video/x-ms-wvx');
                
if (in_array($_FILES[$filename]['type'], $allowed)) {
I've researched all over and have found that video/x-ms-wmv is the mime-type for this file, however, I have tried a half dozen different .wmv file with no luck. They are all 1.3MB or less so there should be no file size issues. I can upload JPG, Quicktime, etc. without issue...so I know it's working, but anytime I try a .wmv file it gives me an error.

Any help or insight into this would be great. I'm on a Linux server. Thanks in advance!!!
Brian

Re: WMV Mime Type Error w/ PHP Upload

Posted: Wed Sep 03, 2008 3:01 pm
by rbc
Anyone have any ideas? I'm at a complete loss. I've spent hours upon hours trying to figure this out. ANY help would be great!

Re: WMV Mime Type Error w/ PHP Upload

Posted: Wed Sep 03, 2008 4:21 pm
by koen.h
After reading this:

http://support.microsoft.com/kb/288102

I would look at having the mime type available somewhere somehow. I don't understand much of it but it seems like your system might need to be able to get to know the mime type. Can you play wmv files on your distro?

Re: WMV Mime Type Error w/ PHP Upload

Posted: Thu Sep 04, 2008 3:44 pm
by rbc
Distro? What's that?

I can play .wmv file is windows media player. I'm on a Mac and using Safari, tried FireFox with the same result. Tied on PC in IE and still had the same trouble. I originaly went to your link and that's how I found the mime types to use in the code.

Re: WMV Mime Type Error w/ PHP Upload

Posted: Thu Sep 04, 2008 4:07 pm
by koen.h
A distro is a flavor of linux, your server. But that doesn't seem to be the problem as you have this result on windows.

Can you put the contents of $_FILE after uploading the media file here?

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 11:00 am
by rbc
If I remove mime type check and try to upload the wmv files they work fine...

I can't put the contents of $_FILE after upload as it doesn't get past the mime type check I guess.

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 11:19 am
by rbc
Ok, I think I found the reason why, but not sure how to resolve this.

Code: Select all

echo $_FILES[$filename]['type'];
When I try to post a .wmv file it displays nothing and when I upload a .mov or .gif or .jpg, etc it displays the appropriate mime type. So when I upload a .wmv it doesn't have a mime type with it it doesn't pass the mime type validation code, so the file doesn't get upload...now, for the real question...why don't the .wmv files have mime types and how can I resolve this so that the validation check works, but allows for .wmv files to be uploaded?

Thanks for your help so far!
Brian

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 11:22 am
by koen.h
The apache server apparently has mime type settings. The one for wmv should be in the list.

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 11:45 am
by rbc
How do I find/add that?

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 12:26 pm
by koen.h
What can you change on your server? Do you have access to the filesystem?

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 12:44 pm
by rbc
Not a ton. I can access the phpini file if it is in there, otherwise, I might have to have the hosting company do it. I just don't know what or where to look or tell them what to do.

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 1:06 pm
by koen.h
Send them a mail to ask if apache is configured to recognize the wmv mime type, and if not whether they could add that.

http://httpd.apache.org/docs/2.0/mod/mod_mime.html

Maybe you can first look at your apache version and loaded apache modules with phpinfo. The module that should be loaded is mod_mime.

I just hope we're on the right track since I don't know much about this stuff.

Re: WMV Mime Type Error w/ PHP Upload

Posted: Fri Sep 05, 2008 3:04 pm
by rbc
Right track or not, it's all I've got to go on at this point. Thanks for your help. I'll see what I can find from my host with regards to Apache and mime types and let you know.