Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Upload a new avatar image to Flarum
// See:
$api_url = sprintf("", $user->id);
// See:
$token = $session->token;
$avatar_file = "/storage/avatars/1234.jpg"; // Absolute path preferred
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'User-Agent: Opera/9.80 (Windows NT 6.2; Win64; x64) Presto/2.12.388 Version/12.15',
'Content-Type: multipart/form-data',
'Authorization: Token ' . $token
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, [
'avatar' => curl_file_create($avatar_file, 'application/octet-stream', 'avatar')
$result = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment