You need to create a module, and define a menu path in it using hook_menu(), and the page callback for that script will be your upload script.
function hook_menu()
{
$menu['mymodule/upload'] = array
(
'title' => 'upload',
'page callback' => 'mymodule_upload_callback',
'access callback' => TRUE
);
return $menu;
//); oops - but not a big enough edit to be accepted
}
Note that you'll need to name your hook in line with Drupal hook naming conventions: https://www.drupal.org/docs/7/creating-custom-modules/understanding-the-hook-system-for-drupal-modules
Then your upload callback:
function mymodule_upload_callback()
{
// Handle your upload here. You will have
// access to public:// and the rest of the Drupal API.
// call drupal_exit at the end() to prevent your
// script from going past this point.
drupal_exit();
}