Make WordPress Core

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#25290 closed defect (bug) (duplicate)

seems can't attach the uploaded photo to the created post

Reported by: zuola's profile zuola Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.6.1
Component: XML-RPC Keywords: XML-RPC attachment
Focuses: Cc:

Description (last modified by dd32)

I can not attach the uploaded photo to the specific post when I using XML-RPC, I found solutions from :

solution below:
I am using :

		DEFINE('WP_USERNAME', 'zola');
		DEFINE('WP_PASSWORD', 'notrealypsw');

		require(dirname(__FILE__) . '/wp-load.php' );
		require(ABSPATH . WPINC . '/class-IXR.php');
		$fs = filesize($_FILES['file']['tmp_name']);
			$file = fopen($_FILES['file']['tmp_name'], 'rb');
			$filedata = fread($file, $fs);
		$data = array(
				'name'  => $_FILES['file']['name'],
				'type'  => strtolower($upfile['type']  ),
				'post'  => $postID, //specific post we want attach to
				'bits'  => new IXR_Base64($filedata),
				false // overwrite
			$status = $rpc->query(
				$uploaded_images__url =$rpc->getResponse();

Wordpress team need add

post = $data['post'];


$name = sanitize_file_name( $data['name'] );
 $type = $data['type'];
 $bits = $data['bits'];

in class-wp-xmlrpc-server.php near 4925 line.

then we can be attach to whatever post we desire!

can anyone fix that issue?

Change History (3)

#1 @dd32
10 years ago

  • Description modified (diff)

I'm fairly certain we support this already.

If the 'post_id' field is present in the $data array, it'll be used (where as you're using the 'post' field).

#2 follow-up: @dd32
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

See [21896] / #13917 which was fixed in 3.5

#3 in reply to: ↑ 2 @zuola
10 years ago

  • Keywords changed from XML-RPC,attachment to XML-RPC attachment

Thanks dd32, I am double check and confirm you are right.

I can post and attach attachment to specific post without hack now.

Note: See TracTickets for help on using tickets.