Search code examples
phpformsubuntuapache2ubuntu-server

PHP $_FILES array remains empty after file upload


I have spent hours trying solve this issue but nothing worked. I am trying to upload a csv file of size 0.5 kb.

This is my html form:

<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit" value="Upload">
</form>

The $_FILES array remains empty after submit:

var_dump($_FILES); // array(0) { }

The $_POST array receives the name of the csv file:

var_dump($_POST); // array(1) { ["file"]=> string(11) "numbers.csv" }

From the php.ini file: (bottom two are commented out in the file)

file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20

;upload_tmp_dir =
;sys_temp_dir = "/tmp"

Perms on /var/tmp folder (if relevant)

drwxr-xr-x 8 root root 4096

Solution

  • My bad I wasn't aware that my form tag is enclosed inside another form tag.

    Not allowed:

    <form>
        <form>
        </form>
    </form>