Skip to content

Instantly share code, notes, and snippets.

@FreeApp2014
Created April 14, 2017 18:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FreeApp2014/54f1502d026dc5ab2e76b2f5a4d70905 to your computer and use it in GitHub Desktop.
Save FreeApp2014/54f1502d026dc5ab2e76b2f5a4d70905 to your computer and use it in GitHub Desktop.
PHP ShareX handler
<?php
//Defining Paths and Variables
$path = "/FreeAppSWServerFiles/screenshot/"; //The path to webroot of this server
$filename = basename($_FILES["file"]["name"]);
$protocol = "http://"; //The protocol used to download file. http or https
$domainname = "scr.freeappsw.ml"; //Domain name
$webroot = "/"; //The path on the website
$FileType = pathinfo($_FILES['file']['name'],PATHINFO_EXTENSION);
$shortname = $filename;
$localfilename = $path."/".$filename;
$webfilename = $protocol.$domainname.$webroot.$filename;
//Handling upload
if ($_FILES["file"]["size"] > 367001600) { //Checking filesize limit
echo "Sorry, your file is too large.";
die();
}
if (move_uploaded_file($_FILES["file"]["tmp_name"], $localfilename)) { //Upload successful
echo $webfilename; //Prints the file name
} else { //Error while uploading
header("HTTP/1.1 401 Bad Request"); //Sends error code so ShareX knows it's an error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment