Q: using space in readfile() I am trying to download an xlsx file using readfile().
The filename is a string variable ($costing_url) which has spaces and is extracted from a MySQL database based on an href'd ID.
Example:
$costing_url="X:\Sys_Prod\WAResponse\Americas Division\2015\OMA - Mexico\ACA (vMUSE AOPS) AATC Costing 09-10-2015 ver(a).xlsx"

This
readfile($costing_url);

--- results in a "failed to open stream" error.
This
readfile("X:\Sys_Prod\WAResponse\Americas Division\2015\OMA - Mexico\ACA (vMUSE AOPS) AATC Costing 09-10-2015 ver(a).xlsx"); 

--- works just fine.
if $costing_url does not have any spaces in the path/filename example A works fine.
Research has indicated that the double-quotes are required to accomodate for the spaces which is what example B proves true.
My problem is that I cannot get the double-quotes escaped properly within the readfile(). I've tried every way I can think of but it will not translate the string ($costing_url) when I try to quote it.
Any help is appreciated.

A: It didn't have anything to do with the spaces. The field in the database had a carriage return <CR> at the end of the field.
Here is a little more detail if others experience a similar issue: I trimmed the string to remove the trailing carriage return
$costing_url = rtrim(costing_url, "\r");

and also changed the readfile line to be
readfile((string)$costing_url);


A: don't use "\", use "/"
ex:
$costing_url= "X:/Sys_Prod/WAResponse/Americas Division/2015/OMA - Mexico/ACA (vMUSE AOPS) AATC Costing 09-10-2015 ver(a).xlsx"
