Limit download speed using PHP

前端 未结 6 2368
北荒
北荒 2020-12-02 13:37

I found on Google some PHP scripts to limit the download speed of a file, but the file download at 10 Mbps or if it download at 80 kbps as i set it, after 5 mb, it stops dow

6条回答
  •  误落风尘
    2020-12-02 14:31

    The reason your download stops after 5MB is because it takes over 60 seconds to download 5MB at 80KB/s. Most of those "speed limiter" scripts use sleep() to pause for a while after sending a chunk, resume, send another chunk, and pause again. But PHP will automatically terminate a script if it's been running for a minute or more. When that happens, your download stops.

    You can use set_time_limit() to prevent your script from being terminated, but some web hosts will not allow you to do this. In that case you're out of luck.

提交回复
热议问题