How to link to files using a relative path? My site is in sites/sandbox folder. When I upload to live server, this will change to sites/mysite 

In file system settings, the public file system path is set to sites/sandbox/files. When site goes live, I plan to change this to sites/mysite/files

File module is enabled and I am uploading PDF files. When entering content, how can I link to an uploaded file using a relative path that won't break when the site goes live?

Or perhaps the site directory name ('sandbox') should never be changed?
Did you try file_create_url() ?

$file_uri = file_create_url(file_build_uri('images/example.jpeg'));

The above snippet will give the file URL. Besides, I recommend transliteration module for the sites that deals with file uploads.