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.

            $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))
              $allowedAudioExt = array('mp3', "wav");
              if (in_array($extension, $allowedAudioExt))
              if (in_array($extension,  $allowVideoExt))
            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??

Recommended Answers

All 2 Replies

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.