Skip to content

Instantly share code, notes, and snippets.

@ingllinasramirez
ingllinasramirez / functions.php
Created July 1, 2024 23:57 — forked from sirbrillig/functions.php
Post file using wp_remote_post in WordPress
<?php
$local_file = 'file_path'; //path to a local file on your server
$post_fields = array(
'name' => 'value',
);
$boundary = wp_generate_password( 24 );
$headers = array(
'content-type' => 'multipart/form-data; boundary=' . $boundary,
);