Skip to content

Instantly share code, notes, and snippets.

@patriksh
Last active June 7, 2023 11:57
Show Gist options
  • Save patriksh/981d409517527ad70cc548f88f5b4767 to your computer and use it in GitHub Desktop.
Save patriksh/981d409517527ad70cc548f88f5b4767 to your computer and use it in GitHub Desktop.
Call of Duty 1.1x screenshots example script
<?php
$webhookUrl = 'YOUR DISCORD WEBHOOK URL';
$targetFile = './' . basename($_FILES['ss']['name']);
$uploadOk = (getimagesize($_FILES['ss']['tmp_name']) !== false);
$uploadOk = (strtolower(pathinfo($targetFile, PATHINFO_EXTENSION)) == 'jpg');
if(!$uploadOk) die;
move_uploaded_file($_FILES['ss']['tmp_name'], $targetFile);
$data = [
'content' => 'New screenshot! Player: `' . $_POST['player'] . '`.',
'file' => new CURLFile($targetFile)
];
$ch = curl_init($webhookUrl);
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $data,
CURLOPT_RETURNTRANSFER => true,
]);
curl_exec($ch);
curl_close($ch);
unlink($targetFile);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment