the problem is because you are passing the file name through the url.
certain characters have special meanings when in a url
- is one of them(it means a space)
these special characters are being decoded either by php or the browser
instead making your urls like this
script.php?file=foo+bar+baz.pdf
do
script.php?<?php echo urlencode('foo+bar+baz.pdf'); ?>
that should solve your problem
also i noticed this line in your script:
readfile('$myfile');
change it to either:
readfile($myfile);
or
readfile("$myfile");
variables inside of single quotes are not expanded in php, the contents inside single quotes is a litteral, so your trying to read a file litterally named $myfile