(PHP 4, PHP 5, PHP 7, PHP 8) Show readfile — Outputs a file Descriptionreadfile(string Parametersfilename The filename being read. use_include_path You can use the optional second parameter and set it to context A context stream resource. Return Values Returns the number of bytes read from the file on success, or Errors/Exceptions Upon failure, an ExamplesExample #1 Forcing a download using readfile()
file_exists($file)) { The above example will output something similar to: Notes
Tip A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen() for more details on how to specify the filename. See the Supported Protocols and Wrappers for links to information about what abilities the various wrappers have, notes on their usage, and information on any predefined variables they may provide. See Also
riksoft at gmail dot com ¶ 8 years ago
simbiat at outlook dot com ¶ 1 year ago
yura_imbp at mail dot ru ¶ 14 years ago
flobee at gmail dot com ¶ 17 years ago
?>
Hayley Watson ¶ 14 years ago
marro at email dot cz ¶ 14 years ago
TimB ¶ 14 years ago
Paulinator ¶ 4 years ago
levhita at gmail dot com ¶ 13 years ago
gaosipov at gmail dot com ¶ 13 years ago
$_SERVER['HTTP_RANGE'])) Anonymous ¶ 3 years ago
chrisputnam at gmail dot com ¶ 17 years ago
?>
daren -remove-me- schwenke ¶ 11 years ago
antispam [at] rdx page [dot] com ¶ 17 years ago
mAu ¶ 15 years ago
planetmaster at planetgac dot com ¶ 16 years ago
peavey at pixelpickers dot com ¶ 16 years ago
Brian ¶ 8 years ago
Thomas Jespersen ¶ 17 years ago
anon ¶ 5 years ago
johniskew ¶ 13 years ago
sakai at d4k dot net ¶ 13 years ago
= '/foo/bar/myfeed.rss'; Elliott Brueggeman ¶ 15 years ago
Zambz ¶ 12 years ago
TheDayOfCondor ¶ 17 years ago
cOrti ¶ 11 years ago
Anonymous ¶ 17 years ago
TheDayOfCondor ¶ 17 years ago
Philipp Heckel ¶ 17 years ago
$types; Anonymous ¶ 7 years ago
$file; Kniht ¶ 15 years ago
chad 0x40 herballure 0x2e com ¶ 15 years ago
kevin dot goodman at itmsoil dot com ¶ 9 years ago
Sinured ¶ 15 years ago
jorensmerenjanu at gmail dot com ¶ 1 year ago
Mike ¶ 12 years ago
How do I get the URL of a PHP file?To get the current page URL, PHP provides a superglobal variable $_SERVER. The $_SERVER is a built-in variable of PHP, which is used to get the current page URL. It is a superglobal variable, means it is always available in all scope.
Can I download a PHP file from URL?You can't do it via http, unless you http server has been configured with a special handler to reveal php source files. This is not typically enabled, and it's not really a good idea to do so, because then anyone can download your PHP code.
How do I download a URL file?Download File from URL. Go to the URL.. Right-click the webpage.. Select Save As.... How can I download file from PHP code?PHP enables you to download file easily using built-in readfile() function. The readfile() function reads a file and writes it to the output buffer.. <? ... . header('Content-Type: application/octet-stream');. header("Content-Transfer-Encoding: utf-8");. |