Specified file failed upload test. Error When Uploading Image From Front-end

This is my code:

$file_return = wp_handle_upload($_FILES['my-photo'], array('test_form' => FALSE));

if(isset($file_return['error']) || isset($file_return['upload_error_handler'])) {
    echo "And so it DIED...";
    print_r($file_return);
    die;
}

Why is not uploading to the uploads dir and why is it throwing a “Specified file failed upload test.”?

3 Answers
3

Check the documentation wp_handle_upload
You need to include the file.php before calling wp_handle_upload

require_once( ABSPATH . 'wp-admin/includes/file.php' )

Leave a Comment