Invalid URI characters?

  list($filename) = $res->fetch_row();
  echo "<!-- $filename -->";
  $filename = str_replace('%20',' ',$filename);
  $filename = str_replace(',','%2C',$filename); 
  $filename = str_replace("'",'%27',$filename);    
//header('Content-type: application/pdf');
echo file_get_contents('PDFs/'.$filename);

The return on this is “The URI you submitted has disallowed characters.”
It only occurs on certain instances of $filename; But changing the name of the file seems to have no effect. I removed all special characters and spaces from the filename… so that $filename contains only [A-Za-z.]

Suppose i should expand the question… is this being caused by an element inside of the PDF file? Is it PHP?

What’s the output of $filename? What line is the error being attributed to?

If all that looks correct, I might try with a text file and see what happens.