Click here to Skip to main content
15,912,457 members

Comments by Manujith Pallewatte (Top 4 by date)

Manujith Pallewatte 21-Nov-13 5:51am View    
it wont work like that since echo $val; would output the hwole file only then it enter the sleep mode
for buffering you also have to do some browser tricks you missed in the above code [please refer that article again, you have to send the 1024 bytes + <br> before everything ]

to acheieve what you want, you have to read the file by a buffer as well
ex:
loop:
read 100 kb from the file
output 100 kb
timer++
if(timer==10) sleep(10);
like wise
Manujith Pallewatte 20-Nov-13 6:04am View    
this isnt an error, this is the directory listing
select the index.php from the directory [although it should be loaded automatically in default configuration]
Manujith Pallewatte 20-Nov-13 5:47am View    
you need to flush the buffer to break it, you need to tweak the browser to support this feature
i assume that the data you are transferring is okay with this breaking, following tip shows how to output php in realtime, in which the buffer is interrupted to show the output. Same concept can be used to tell the browser to stop receiving at a given time.
http://www.codeproject.com/Tips/680085/Real-time-Updating-of-PHP-Output

read more about http://php.net/manual/en/function.ob-flush.php (ob_flush()) as well

Manujith Pallewatte 20-Nov-13 1:05am View    
heyy,
its your good time, only last week i made a php -> js library for just this purpose :)
https://github.com/ManZzup/pjstreamer
now this is actually not made for transfering byte data, but with some modifications you can make it transfer bytes over ajax
----------------
OR you can modify the solution to buffer data than downloading periodically, that is you tell the browser that the file is buffering and the browser will download byte stream till the server stops sending