Post file using wp_remote_post in WordPress

WordPress HTTP API standardize the HTTP requests to allow using a single function instead of providing different method supports based on web hosting.

Instead of directly using curl or any other method, you can use the WordPress HTTP API.

wp_remote_post allows you to send a HTTP post request, but it doesn’t support sending file over to the URL.

For Posting a file using wp_remote_post, you can use the hack given below, It was originally  suggested by David Anderson in WordPress mailing list.

It works perfectly fine, however for bigger file size it might have some issues.

2 thoughts on “Post file using wp_remote_post in WordPress”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.