file_get_contents()
over the HTTP wrapper does not directly download the file if the file has been pre-parsed by the webserver.
Take the following example: if you call file_get_contents()
on a remove webpage (example.com/foobar.php
), you won't be presented with the source code of foobar.php
, but how the webserver of example.com
parses the PHP file. So you will only be able to retrieve the generated HTML output.
If the filename is not present in the URL and there is no way that you can fetch it from anywhere, then you are in a dead end. Data can't be just summoned from the transcendental field of datum.
For alternative solutions, I can only suggest using the cURL
library (it is used to handle queries from your server (as it were a client) to other servers with using URL, hence the name cient URL) or file sockets. Here is another question's answer on Stack Overflow which describes how to fetch filename using cURL
.
Also, you might try getting in touch with the administrator/maintainer/webmaster team of domain.com
, asking if they had a publicly available API to fetch filenames and other metadata.