WordPress.org

Ready to get started?Download WordPress

Forums

wp_handle_upload (6 posts)

  1. callmeforsox
    Member
    Posted 5 years ago #

    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?

  2. foxinni
    Member
    Posted 4 years ago #

    I've been trying for hours now to get this fixed!

    Exact same problem. Any help will be great.

    Thanks.

  3. foxinni
    Member
    Posted 4 years ago #

    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.

  4. foxinni
    Member
    Posted 4 years ago #

    Bump..

  5. David C
    Member
    Posted 4 years ago #

    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);

  6. dameer
    Member
    Posted 4 years ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic