here is code that I am working on.
What it is supposed to do is upload a media file (image, audio, video) and then tell me what type of media it is.

            $media_type='image';
            $filename=$_FILES["file"]["name"];
            $extension = explode(".", $filename);
            $extension = end($extension);
            //echo $extension;
            if (($_FILES["file"]["size"] < 50000)
            && (!$_FILES["file"]["error"] > 0) )
            {
              $allowedPicExt = array("jpg", "jpeg", "gif", "png");
              if (in_array($extension, $allowedPicExt))
                {           
                    $media_type='image';
                } 
              $allowedAudioExt = array('mp3', "wav");
              if (in_array($extension, $allowedAudioExt))
                {           
                    $media_type='audio';
                }
              $allowVideoExt=array("mp4","ogg");
              if (in_array($extension,  $allowVideoExt))
                {           
                    $media_type='video';
                }
            }
            echo "--".$extension."--".$media_type;

Tested it with a png and it gives me back --png--image
Tried it with a mp3 and then only gives me back --mp3--

I have looked at every angle on this one but not seeing what I am doing wrong. The part that saves the file is not shown, but it does work and saves the file as it is supposed to...

Any advice??

Is the file less than 50000 bytes and is there definitely not an error code set in the $_FILES array?

Perhaps try adding an else to the if statement on line 6, to var_dump the $_FILES array.

try this website, it will help you to use mime content type. Hope that helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.