curl - PHP downloading question -


On my site, users can link input from files and I can stream the download process from my server. I use a system like this:

  header ('cache-control: private'); Header ('content-type: application / octet-stream'); Header ('Content-Length:'. $ R [2]); Header ('content-dispute: file name ='. $ TheName); Flush (); $ File = fopen ($ fileName, "r"); While (! FIFF ($ file)) {print fread ($ file, 10240); Flush (); Sleep (1); } Fclose ($ fileName);  

It looks like my users download very slow (600kb / s), the hosted server is on a 1 GB of port so they have to multiply their internet connection. needed.

I am thinking that there is a better way to talk like this, maybe it might be rude? I do not have much experience with curls, but I appreciate any feedback.

Thank you.

If you insist on your attitude, then it will be much more efficient in this way, without flush and sleep:

  while (! Fife ($ file)) { Print Fred ($ file, 10240); }  

Here's why:

  • You stop normal buffers by using flush (), and
  • sleep (1), you effectively reduce the speed of transfer by pausing for 1 second every 10 kb.

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -