Page 1 of 1

[solved]Weird problem upload routine.

Posted: Fri Nov 18, 2005 10:21 pm
by dreamline
Hi Guyz,
I've written an upload routine for MP3's. It's nothing special, but it seems that some people get an error (File is not an MP3) while the file is OK. When people send me the file through email and i upload it myself there isn't any problem and the routine works just fine. You can see the checking code below.

Anybody know of a glitch what can cause the above problem.

Code: Select all

if (is_uploaded_file($_FILES['mp3file']['tmp_name']))
  {
   $filetype = $_FILES['mp3file']['type'];
   $filesize = $_FILES['mp3file']['size'];
   $filename = $_FILES['mp3file']['name'];
   if (($filetype == "audio/mpeg") || ($filetype == "audio/mpeg3") || ($filetype == "audio/x-mpeg-3"))
     {
     if (!ereg(".mp3",$filename))
      {
      Echo("Error wrong extension");
      }
   }
   else
   {
   Echo("Error file is not a MP3");
   }

Posted: Fri Nov 18, 2005 11:03 pm
by AKA Panama Jack
Your best bet at tracking down the problem is to change your error line to this...

Code: Select all

Echo("Error file is not a MP3 - Detected Filetype: $filetype");
This way it will display the filetype so the person reporting the problem can tell you exactly what the server thought was being sent.

Posted: Fri Nov 18, 2005 11:51 pm
by dreamline
Thanks, i'll give it a go.. :)

Posted: Sat Nov 19, 2005 12:15 am
by josh
Most likely their browser isn't sending the mime type, check it manually http://us3.php.net/manual/en/function.m ... t-type.php

Posted: Sat Nov 19, 2005 5:52 am
by dreamline
K, i implemented to see if the mime type is actually sent, so hopefully this will get me an insight of what mime type is actually sent.

If i know that then i can follow your instructions jshpro2... :)

Thanks to both for helping.. :D

Posted: Sat Nov 19, 2005 7:36 am
by yum-jelly
On one of my forums I allow mp3 uploads, here is a list of all the mime types that different browsers have sent for 3,456 uploaded mp3 files for ring tones.


audio/mpeg
audio/mpeg3
audio/x-mpeg3
audio/mpeg-url
audio/x-mpeg-url
application/x-mp3



yj

Posted: Sat Nov 19, 2005 8:19 pm
by dreamline
Thanks for the mime types, i'm most definately not using a few of them.... :)