How to delete file uploaded by Plupload

To delete a file from the file system, you can use something like this attached to an AJAX hook that is called by jQuery:

function ajax_remove_image() {
    check_ajax_referer( 'image_removal', 'image_removal_nonce' );

    if ( ! $_POST[ 'confirm' ] )
        exit( 'false' );

    $uploads       = wp_upload_dir();
    $upload_dir    = $uploads[ 'path' ];
    $file          = strpos( $_POST[ 'file' ], "https://wordpress.stackexchange.com/" ) !== false ? $_POST[ 'file' ] : $upload_dir . "https://wordpress.stackexchange.com/" . $_POST[ 'file' ];
    $attachment_id = null;

    @unlink( $file );

    if ( ! file_exists( $file ) )
        exit( 'true' );
    else
        exit( 'false' );
}

This code comes from a plug-in that I am currently working on (source), so you may have to adjust it as necessary.