I try to accept a file using php:
<?php
if (isset($_FILES["file"])) {
$uploaddir = '/';
$uploadfile = $uploaddir . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
echo "File is valid, and was successfully uploaded.n";
} else {
echo "Error";
}
}
I send Postman request as POST form-data
: file: Filename
.
Why I always get echo "Error";
?