wp_handle_upload issue 指定文件上传测试失败

cus*_*OOM 1 wordpress

使用 wp_handle_upload 函数时,它返回以下错误

 Array([error] => Specified file failed upload test.)
Run Code Online (Sandbox Code Playgroud)

我使用的代码如下

function dc_form_image_upload() {
    if ( ! function_exists( 'wp_handle_upload' ) ) {
        require_once( ABSPATH . 'wp-admin/includes/file.php' );
    }

    $uploadedfile = $_POST['file'];
    //print_r($uploadedfile);
    // die();

    $upload_overrides = array( 'test_form' => false );

    $movefile = wp_handle_upload( $uploadedfile, $upload_overrides ); 

    if ( $movefile && !isset( $movefile['error'] ) ) {
        echo "File is valid, and was successfully uploaded.\n";
        var_dump( $movefile);
    } else {
        /**
         * Error generated by _wp_handle_upload()
         * @see _wp_handle_upload() in wp-admin/includes/file.php
         */
        print_r($movefile);
    }
}
Run Code Online (Sandbox Code Playgroud)

标准管理媒体上传工作正常,但这似乎引起了问题。

任何人都可以就此给我一些建议,更新ini文件等等,但没有任何改进。

谢谢。

cus*_*OOM 5

问题是我得到了以下信息

$uploadedfile = $_POST['file']
Run Code Online (Sandbox Code Playgroud)

而不是得到

$uploadedfile = $_FILES['file']
Run Code Online (Sandbox Code Playgroud)