media_handle_upload() returns Specified file failed upload test

Question

I am trying to make media_handle_upload() work but I keep getting ‘Specified file failed upload test.’
This is how I am testing it:

`

if ( isset($_FILES["dlkimage1"]) && !empty($_FILES["dlkimage1"]["tmp_name"]) )
    $image_id = media_handle_upload(
                        $_FILES["dlkimage1"]["tmp_name"],   // file
                        0,                                  // ID of image post
                        array(),                            // post data (to overwrite some of the attachment)
                        array('test_form' => false) );
if ( is_wp_error($image_id) )
    echo 'ERROR: ' . $image_id->get_error_message();
else
    echo $image_id;

?>
Update Preview

`

What am I missing?

0
, , marcnyc 8 months 0 Answers 94 views 0

Leave an answer