From 19723c932cad1d7f29db90316d63bcb87564d876 Mon Sep 17 00:00:00 2001 From: Joe Robinson Date: Fri, 11 Dec 2015 16:30:41 +0000 Subject: Add option to send notification to a URL when a file is uploaded --- upload_file.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'upload_file.php') diff --git a/upload_file.php b/upload_file.php index 890078a..3f35524 100644 --- a/upload_file.php +++ b/upload_file.php @@ -51,8 +51,26 @@ if ($_FILES["file"]["error"] > 0) { $fileurl = "$url" . $_FILES["file"]["name"]; echo "URL: $fileurl
"; echo "Size: " . size_readable($_FILES["file"]["size"], null, "bi"); + if (isset($notificationurl)) { + send_upload_notification($fileurl); + } } } + +function send_upload_notification($fileurl) { + $data = array('url' => $fileurl, 'channel' => $notificationchannel); + + $options = array( + 'http' => array( + 'header' => "Content-type: application/x-www-form-urlencoded\r\n" . + "X-Blaears-Event: blaupload", + 'method' => 'POST', + 'content' => http_build_query($data), + ), + ); + $context = stream_context_create($options); + file_get_contents($url, false, $context); +} ?>

-- cgit v1.2.3