$_FILES empty after postman upload

Viewed 27

I am using plain php to uplaod a file. If i try testing it with postman the FILE array is empty. I know there are a lot of similar questions out there, but I they all have either a different setup, or have some simple mistakes, but I am pretty sure I checked all common errors like php.ini values and such. Here is my Php code and the postman request:

foreach ($_POST as $key => $value)
{
    echo($key . ": " . $value);
}
foreach ($_FILES as $key => $value)
{
    echo($key . ": " . $value);
}
echo(count($_FILES));

enter image description here

Here are the values of my php.ini

file_uploads = on
upload_max_filesize = 2000M
post_max_size = 2000M

Does anybody have an idea what else I could be doing wrong?

1 Answers

The main issue is $_FILES here will give you single dimensional array because you are using a single file upload, so foreach ($_FILES as $key => $value) will not work.

To make it work you need to send multiple files and for that, you need to make key like barcode[]

Related