将$ _FILES作为变量传递,返回结果和错误。

Trying to execute file upload through external function. It gives "Missing argument..." error but also returns the result correctly. What might be wrong?

This is form page:

<?php include '--formprocess.php'; ?>
<?php
if($_SERVER['REQUEST_METHOD'] === 'POST') {
    $upload = $_FILES['upload'];
        if(formprocess($upload)) {
        echo formprocess();
    } else {
        echo 'ERROR!';
    }
}
?>

and process file:

<?php
function formprocess($upload) {
    $name = $_FILES['upload']['tmp_name'];
    return $name;
}
    echo formprocess();
                     ^---your missing argument

formprocess takes one argument, the first time you call it you passed an argument, the second time you did not.

$value = formprocess($upload);
if($value) {
    echo $value;
}