Skip to content
Advertisement

PHP 8.1 $_FILES missing type property

I am upgrading my website from PHP 7.4 to 8.1 which is causing an unusual issue with $_FILES. I’m trying to upload a new file but nothing happens. This issue cannot be regarding the file size as I’m trying to upload .txt files containing a single word.

Example of my code:

<form action="client.php" method="POST" enctype="multipart/form-data" onSubmit="javascript: return validateFile(this);">
    <div class="card-header">
        Upload Section
    </div>
    <div class="card-body">
        <div class="position-relative form-group">
            <label >Select file from local disk</label>
            <input  type="file" name="test" size="90" maxlength="500" class="form-control-file">
        </div>
        <input class="mt-1 btn btn-primary" name='Submit' type='submit' value='Upload File'>
    </div>
</form>

When the from is posted the data within $_FILES is like so

test={ name="test.txt, full_path=test.txt, type="", tmp_name="", error={int} 6, size={int} 0}

Advertisement

Answer

The PHP website did not have access to the “C:WINDOWSTemp” directory. Which was easily fixed by changing the security permissions.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement