file_get_contents('http://localhost/project/ds_FWREF#1801\msg_1_ds_FW SYSREF#180133.json');
this returns below error
[function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found.
Note, the file exists in that particular location but, I'm unable to access due to a #
in file name and dir name.
#
is a special character in URLs. It marks the beginning of the fragment.
In order to use its literal value in an URL it has to be properly URL-encoded.
Pass the file name to function urlencode()
to produce the correct URL for it. It takes care of all characters that are special in URLs (/
, &
, =
, #
, ?
, %
, etc.)
$filename = 'ds_FWREF#1801\msg_1_ds_FW SYSREF#180133.json';
$content = file_get_contents('http://localhost/project/'.urlencode($filename));