6

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.

11
  • Are you sure the bad file is encoded properly and is not corrupt? Commented Apr 24, 2015 at 0:17
  • Have you looked at your max_post_vars/max_input_vars variables? Commented Apr 24, 2015 at 0:32
  • @Darren nothing is currently set, I'll add them and have a play to see if there is any change in the result. Would changing the max vars really have an effect on it when I'm only using 2 inputs. Commented Apr 24, 2015 at 0:56
  • @Bankzilla It might not affect anything but I ran into something similar and changing the upload size and these two variables managed to fix it! Commented Apr 24, 2015 at 0:57
  • 1
    @Darren you might be onto something, I believe settings the max_input_vars to 3000, I'm now getting the error POST Content-Length of 10237675 bytes exceeds the limit of 8388608 bytes in Unknown Commented Apr 24, 2015 at 1:00

1 Answer 1

8

The issue you are facing is due to the fact that post_max_size is set to 8M as default in your php.ini. As your file is 10.4MB you run into the following error:

POST Content-Length of 10237675 bytes exceeds the limit of 8388608 bytes in Unknown

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:

php_value post_max_size 20M
php_value upload_max_filesize 20M

Note: I've also added the required upload_max_filesize that you will require for the bigger files :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.