wp_handle_upload issue Specified file failed upload test

When using the wp_handle_upload function it is returning the following error

 Array([error] => Specified file failed upload test.)

The code I am using is as follows

Read More
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);
    }
}

Standard admin media upload is working fine but this seems to be causing issues.

Can anyone give me some advice on this, have updated ini files and so on with no improvement.

Thanks.

Related posts

1 comment

  1. Problem was I was getting the following

    $uploadedfile = $_POST['file']
    

    instead of getting

    $uploadedfile = $_FILES['file']
    

Comments are closed.