php download script

edited 十月 2013 in 進階PHP討論
I got a php file download script, which is using readfile to send the file to user. But the file size is quite large (around 30MB), while sending the file, the apache server is not responding to any other request. Anyone got an idea to solve this problem? I am thinking if I can work around the problem by reading the file in serval sequences, say 1MB size for each, then sleep for 1 seconds then resume the reading until eof, is it ok ?

Many thanks.



  • edited 二月 2007
    也許在這兒可以用中文討論 :)

    如果希望沿用 readfile 形式就需要調整系統設定讓 PHP 能夠存取更多的記憶體,只是這樣一來會衍生其他問題;程式當然可以改成每次讀取 1MB 的資料量,只是中間還要間隔一秒可能會讓大部分的瀏覽器判斷為沒有回應而終止連結。比較常見的形式是去限制同時間的連線數量,如果人太多就出現訊息要他等一會兒再下載。
Sign In or Register to comment.