POST array is empty when containing a file

2019-07-17 04:39发布

问题:

I have a simple HTML form containing a file input. When the form is submitted without a file, printing the $_POST array shows me all of the data submitted. When a file is submitted, however, $_POST doesn't print out any of the submitted data.

Can somebody tell me why? This is my code:

<?php
    print_r($_POST);
?>
<form action="test.php" method="post" enctype="multipart/form-data">
    <label for="myfile">Video File:</label>
    <input type="file" name="myfile" />
    <br /><br />
    <label for="mytitle">Title:</label><br />
    <input type="text" name="mytitle" size="55" maxlength="60" />
    <br /><br />
    <input type="submit" name="mysubmit" value="Submit Video for Approval" />
</form>

回答1:

Your script seems fine. Please check your server configuration. Perhaps you exceed POST limits (set with post_max_size in php.ini)



回答2:

You have to use $_FILES to access the uploaded files.

var_dump($_FILES); // Your uploaded files
var_dump($_POST);  // Your entered data