"Jake Wiley" <OEKilla@msn.com> wrote in
news:1108260391.744238.99650@c13g2000cwb.googlegro ups.com:
[color=blue]
> I'm trying to create an mp3 upload page but noticed that the mime type
> on my laptop is audio/mp3 while on my desktop it is audio/mpeg. I want
> to allow both types to upload.
> I have tried this:
> if (($_FILES['userfile']['type'] != 'audio/mp3') ||
> ($_FILES['userfile']['type'] != 'audio/mpeg'))
> {
> echo an error message
> then exit the program
> }
>
> I tried several variations of this but as soon as it finds that it
> doesn't meet the first criteria it aborts even though it is of
> audio/mpeg type.[/color]
Once you fix the logic error(OR vs AND), you should consider
that the above logic may not be robust enough:
- the client(the browser) may not provide the mime type
- the client may provide a different mime type, even though
the file is an mp3 file
- the client may be spoofing the mime type
--
Dave Patton
Canadian Coordinator, Degree Confluence Project
http://www.confluence.org/
My website:
http://members.shaw.ca/davepatton/