WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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


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.