Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'am developing a plugin that will push files to a remote server via http upload. Currently I got it to work with CURL doing something like this:

$post = array("post_file"=>"@/path/FILE.EXT");
curl_setopt($ch, CURLOPT_POSTFIELDS, $post); 

Now my question is how I can achieve the same using wp_remote_host. How is the file included in the 'body' argument.

For more info see this. http://codex.wordpress.org/Function_API/wp_remote_post

share|improve this question

2 Answers 2

Something like this, perhaps.

$args['body'] = array('post_file'=>'@/path/FILE.EXT');
wp_remote_post($url, $args);

The $args array contains the parameters for the post. The body parameter controls what is posted. There's many other possible parameters as well. See http://codex.wordpress.org/HTTP_API#Other_Arguments

Note that the @file method may be specific to curl, and might not work with the other possible HTTP transports that WP supports.

share|improve this answer

I read through the source code in wp-includes/class-http.php and wp_remote_post() doesn't support sending files. I think you'd need to re-write the WP_Http class to make this work or otherwise write a plugin or extension to handle this.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.