sylvest Posted May 21, 2018 Share Posted May 21, 2018 I have a requirement for my PHP pages sometimes to send files (e.g. images, CSS files, JS files, fonts) to the client. The normal way to do this seems to be to use the readfile() function, but I understand that this reads the whole file into memory and then sends it to the client, which will cause problems if it is a very large file. I understand that there is an Apache module mod_xsendfile which does a better job, but Support tell me that this is not available on my shared server. So my question is, what is the best/most efficient way of sending files to the client in PHP, without mod_xsendfile? Do I have to write a loop that reads the file a few K at a time and sends each chunk to the client before reading the next? If so, has anyone got this code already working that they would be happy to share with me, to save a bit of time? Thanks - Rowan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.