WMV Mime Type Error w/ PHP Upload

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
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

WMV Mime Type Error w/ PHP Upload

Post 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
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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!
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: WMV Mime Type Error w/ PHP Upload

Post 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?
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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.
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: WMV Mime Type Error w/ PHP Upload

Post 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?
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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.
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: WMV Mime Type Error w/ PHP Upload

Post by koen.h »

The apache server apparently has mime type settings. The one for wmv should be in the list.
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post by rbc »

How do I find/add that?
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: WMV Mime Type Error w/ PHP Upload

Post by koen.h »

What can you change on your server? Do you have access to the filesystem?
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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.
koen.h
Forum Contributor
Posts: 268
Joined: Sat May 03, 2008 8:43 am

Re: WMV Mime Type Error w/ PHP Upload

Post 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.
rbc
Forum Newbie
Posts: 22
Joined: Tue Sep 02, 2008 6:00 pm

Re: WMV Mime Type Error w/ PHP Upload

Post 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.
Post Reply