Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_FILES and $_POST data empty when uploading certain files

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.

like image 800
Bankzilla Avatar asked Apr 24 '15 00:04

Bankzilla


1 Answers

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 :)

like image 76
Darren Avatar answered Sep 28 '22 08:09

Darren