I decided.
I just open a file with PHP that I want to send to the client.
$fh = fopen($filePath, 'r');
Then I calculate 60% of the file size by writing
$fileSize = filesize($filePath); $sizeFirst = floor(($fileSize / 100) * 60);
Now the $ sizeFirst variable contains the length of the first 60% of the file in a numerical value. To calculate the remaining 40%, I use:
$sizeLast = $fileSize - $sizeFirst;
Now I can record the first 60%, perform my action, and then write outh the remaining 40%.
$dataFirst = fread($fh, $sizeFirst); echo($dataDirst); // Do my action here. $dataSecond = fread($fh, $sizeSecond); echo($dataSecond); exit();
I need to set header (); Before displaying this, you must specify Content-length, Content-type and Content-Disposition in order to send the client a valid header and file.
Hope this helps someone.
Tark
source share