Movie2.mp4 which has no value for $_FILES["file"]["type"]

I have 3 files, i.e., image1.jpg, movie1.mp4, and movie2.mp4 in my mobile phone.

And I have “uploadAction.php” for uploading the files which has the code below.

$loadingName = $_FILES['file']['name'] ;
$loadPath = 'myPath/' .$loadingName ;
move_uploaded_file($_FILES["file"]["tmp_name"], $loadPath) ;

When I try to upload image1.jpg, it is successfully uploaded.

When I try to upload movie1.mp4, it is successfully uploaded.

However,
When I try to upload movie2.mp4, it is not uploaded.

So I added the code below for seeing what is the problem.

echo $_FILES["file"]["type"] ; 

After I added the code above in the page “uploadAction.php”, I try to upload the files image1.jpg, movie1.mp4, and movie2.mp4.

When I try to upload image1.jpg, it says “image/jpeg”.

When I try to upload movie1.mp4, it says “video/mp4”.

When I try to upload movie2.mp4, it says NOTHING.

Movie2.mp4 has no value for $_FILES[“file”][“type”] .

How can I make movie2.mp4 to upload successfully?

What is

$_FILES[‘file’][’error’]

Telling you?

With the code below,

echo $FILES["file"]["error"] ;

When I try to upload image1.jpg, it says “0” and it is uploaded.

When I try to upload movie1.mp4, it says “0” and it is uploaded.

When I try to upload movie2.mp4, it says “1” and it is NOT uploaded.

Is movie2 considerably bigger than movie1?

Error 1 indicates the file was too big.

Movie1 is 15.65MG.
Movie2 is 52.58MG.

I open the php.ini.

I change the following.

before: post_max_size=500M
upload_max_filesize=40M

after: 
post_max_size=1000M
upload_max_filesize=300M

And movie2.mp4 is successfully uploaded.
Thank you very much.

1 Like

Setting those to large values isn’t the correct solution. Someone can now tie up your server uploading Gigabyte size files (the post_max_size setting) that will produce an error since they are greater than the uplaod_max_filesize.

You should instead set those values to be reasonable values that YOU want for uploaded files and you need to add error handling in the file upload form processing code to let the visitor know when they have exceed either of the settings. Exceeding the post_max_size setting will cause both the $_POST and $_FILES arrays to be empty. Exceeding the upload_max_filesize setting will cause the [‘error’] element to be a 1, like you were getting.