src/web/UploadedFile.php
public function save_as($file, $delete_tmp = true): bool {
        $file = \Mii::resolve($file);

        if ($this->error == UPLOAD_ERR_OK) {
            if ($delete_tmp) {
                return move_uploaded_file($this->tmp_name, $file);
            } elseif (is_uploaded_file($this->tmp_name)) {
                return copy($this->tmp_name, $file);
            }
        }
        return false;
    }
public function save_as($file, $delete_tmp = true): bool {
        $file = \Mii::resolve($file);

        if ($this->error == UPLOAD_ERR_OK) {
            if ($delete_tmp) {
                return move_uploaded_file($this->tmp_name, $file);
            } elseif (is_uploaded_file($this->tmp_name)) {
                return copy($this->tmp_name, $file);
            }
        }
        return false;
    }
Saves the uploaded file.
Note that this method uses php's move_uploaded_file() method. If the target file `$file`
already exists, it will be overwritten.
@param string $file the file path used to save the uploaded file
@param bool $delete_tmp whether to delete the temporary file after saving.
If true, you will not be able to save the uploaded file again in the current request.
@return bool true whether the file is saved successfully