I've noticed that depending on the video I'm uploading that sometimes the entire $_POST
and $_FILES
array will be empty. This is an odd occurrence but I have found it in a few videos. For the sake of testing the videos I was using are all of video/mp4
file type.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<?php
var_dump($_POST);
var_dump($_FILES);
?>
<form method="post" action="" enctype="multipart/form-data">
<input type="file" name="attachment">
<input type="text" name="other">
<button type="submit" class="save" value="Save Changes">Upload that file!</button>
</form>
</body>
</html>
The output of a good video is
Array
(
[other] => testing string
)
Array
(
[attachment] => Array
(
[name] => Shasta.mp4
[type] => video/mp4
[tmp_name] => /private/var/tmp/phpAoDLKi
[error] => 0
[size] => 4688949
)
)
While a bad request displays the following
Array
(
)
Array
(
)
I've modified my php.ini to allow file uploads to the size of 50mb, the files I'm testing with are 4.7mb and 10.2mb. I'm completely stumped on what the cause is, the video file names are Shasta.mp4
(good file) and Bulova_Watches.mp4
(bad file).
If need be I can upload the files to a site for others to test.
The issue you are facing is due to the fact that
post_max_size
is set to8M
as default in yourphp.ini
. As your file is10.4MB
you run into the following error:Because you've reached that limit. The trick to fixing this is to simply up that limit by changing the value. You could simply change it directly in your php.ini file to whatever you desire, i.e. 20M.
Or you could set it via your
.htaccess
file with:Note: I've also added the required
upload_max_filesize
that you will require for the bigger files :)