Facing problem in downloading big files
Posted: Sun Nov 23, 2008 7:32 am
Hi!
I am working on a simple project which is some how related to download a big file (80MB), while hiding the actual physical location of file from the user, I am doing this by writing a simple php file, which takes ID of file as argument and then from database picks the name of file and then simply write the file to input stream of client browser.. All the things are working fine but problem is that while downloading the big file, if user wants to open some other link of my website it doesn't work untill the download is complete.... Or He/She opens another browser window and start surffing from there....which is unacceptable for me.... It seems that server and client are working on single thread model which is obviously not true.. here is the code snippet of my download.php file..
the readfile function I am using is putting whole of 80MB file in one attempt to input stream of client browser, I know that the problem is due to this function, but how to reolve it? Please let me know, if any one can help me as soon as possible, I would really appreciate it! I expect some help from PHP Gurus!
Regards
Bye
Ummar
I am working on a simple project which is some how related to download a big file (80MB), while hiding the actual physical location of file from the user, I am doing this by writing a simple php file, which takes ID of file as argument and then from database picks the name of file and then simply write the file to input stream of client browser.. All the things are working fine but problem is that while downloading the big file, if user wants to open some other link of my website it doesn't work untill the download is complete.... Or He/She opens another browser window and start surffing from there....which is unacceptable for me.... It seems that server and client are working on single thread model which is obviously not true.. here is the code snippet of my download.php file..
Code: Select all
<?php
$fSize = filesize("myvideos/videos/testvideo.flv");
header('Content-transfer-encoding: binary');
header('Content-Type: video/x-flv');
header('Content-Length: '.$fSize);
header('Content-Disposition: attachment; '.'filename='testvideo.flv'");
header ("Pragma: public");
header ("Expires: 0");
header ("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header ("Cache-Control: private");
ob_clean();
ob_end_flush();
readfile("myvideos/videos/testvideo.flv"); /*Write file to out put stream*/
?>
Regards
Bye
Ummar