For small files you should use readfile
, that makes all for you to send a file to the client. For really big files these function probably don't work due to memory problems.
Also there is a function file_get_contents
to get all file content into a variable if you require to process it before send. Like readfile
is recommended only for "small" files. "small" depends on the memory allowed to run a PHP process (memory_limit
parameter in php.ini). Usually servers set it from 8M to 128M and by default is 16MB.