user3753569
user3753569

Reputation: 1853

PHP file upload not working for mp4

I am checking if the file is of mp4 format once a user submits the form, this does not work for me:

if(!($_FILES["videoFile"]["type"] == "video/mp4"))
{
   // error handling
}

The file type works for other file types such as png/jpg ect but not for mp4.

echo $_FILES["videoFile"]["type"] = [tmp_name] 
echo $_FILES["videoFile"]["name"] = movie_300.mp4

when I print out the array of files i get:

Array ( [videoFile] => Array ( [name] => movie_300.mp4 [type] => [tmp_name] => [error] => 1 [size] => 0 ))

Why is my file type [tmp_name] when uploading mp4s?

Upvotes: 2

Views: 1321

Answers (2)

The Blue Dog
The Blue Dog

Reputation: 2475

You've exceeded your maximum file upload size, see here.

You can increase this using the following directive at the top of your script:

ini_set('upload_max_filesize', '10M'); // set max size to 10M (or whatever)

Upvotes: 2

DeFeNdog
DeFeNdog

Reputation: 1210

Here's a neat little function.

http://subinsb.com/php-find-file-mime-type

I'd be careful with your validation because I'm pretty sure mimes can be spoofed fairly easily. Maybe someone with more security experience can weigh in on that subject. I'd at least perform a few other checks.

Cheers!

Upvotes: 0

Related Questions