Support » Plugins and Hacks » wp_handle_upload


  • I’ve been trying to write a plugin to upload photos on the post write page. I’ve been trying to use wp_handle_upload to handle the image uploading but I’m always getting “Specified file failed upload test.” which means the tmp files don’t match. Yet, the file still uploads to the upload dir, just that it throws an error which causes the plugin to exit.

    Anyone know of a solution?

Viewing 5 replies - 1 through 5 (of 5 total)
  • I’ve been trying for hours now to get this fixed!

    Exact same problem. Any help will be great.


    If I go to wp-admin/includes/file.php on line 297 and comments out

    // Move the file to the uploads dir
    	$new_file = $uploads['path'] . "/$filename";
    	if ( false === @ move_uploaded_file( $file['tmp_name'], $new_file ) ) {
    		return $upload_error_handler( $file, sprintf( __('The uploaded file could not be moved to %s.' ), $uploads['path'] ) );

    Then the correct return is produced, but obviously the file does not get uploaded. If gotten this to work perfectly on a custom admin page.




    I’d have to see your code but make sure you are overriding the test form before you try to call the upload function.

    $overrides = array(‘test_form’ => false);

    I’m performing some test on that subject…

    require_once( ABSPATH . 'wp-admin/includes/file.php' );
    $overrides = array( 'action' => 'wp_handle_upload' );
    $file = wp_handle_upload( $_FILES[ 'entryImage' ], $overrides );

    …where ‘entryImage’ is supposed to be input type=”file”. Does it make any sense to ya?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘wp_handle_upload’ is closed to new replies.