Cann't check a file extension in php

78 views Asked by At

The case statement in php here to check a mime type is working fine.

$mimetype = mime_content_type($path);
switch ($mimetype) {

    case "video/mp4":
    case "video/mov":
~~~~~~~~~~~~~~~~~

However, the case statement in php here to check a file extention is not, and in this case pathinfo($path) is not extracting a filename such as VID_2_134.mp4. I guess the way I used pathinfo($path) is not correct, but I don't know the correct way to use it. If I replace pathinfo($path) with VID_2_134.mp4 below the case statement starts to work with the way I expected.

$filepath = pathinfo($path);
$extension = $filepath['extension'];
switch ($extension) {

     case "mp4":
     case "mov":
~~~~~~~~~~~~~~~~~

*$path is a file path from the local drive of pc or smartphone where the file exist.

Can anyone please help me out?

0

There are 0 answers