Specified file failed upload test. wp_upload_handle

So I managed to write a peice of code that allows me to upload a zip file, im not even sure where it gets uploaded too, and I am doing it on my localhost with apache in control (www-data). the code is as follows:

public function upload_file(array $file){
    add_filter('upload_mimes', array($this, accepted_mime_type));

    if(wp_handle_upload($file, array('test_form' => false))){
        var_dump(wp_handle_upload($file, array('test_form' => false)));
    }else{
        $this->error('Oops!', 'Something went wrong with the upload. Please try again.');
    }       
}

the error I get is: Specified file failed upload test

Read More

Im not sure whats going on, this is localhost.

Related posts

1 comment

  1. The error you are seeing is coming from wp_handle_upload():

    // A properly uploaded file will pass this test. There should be no reason to override this one.
    if ( $test_upload && ! @ is_uploaded_file( $file['tmp_name'] ) )
        return call_user_func($upload_error_handler, $file, __( 'Specified file failed upload test.' ));
    

    I am not sure about your context, but what you are trying to do seems to not be POST upload and as such fails is_uploaded_file() check.

Comments are closed.