On my local development I use the code shown below, which works perfect,
but when I uploaded the site to my shared hosting everything worked fine except my file upl
Simply use this
$_SERVER['DOCUMENT_ROOT']."/path/to/directory"