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??

5 Years
Discussion Span
Last Post by fobos

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.