0

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

3
Contributors
2
Replies
19
Views
4 Years
Discussion Span
Last Post by fobos
0

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.