Streaming local file from PHP while it’s been written to by a CURL process


Posted on 16th Feb 2014 07:03 pm by admin

I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a different discussion. Here's the code:

shell_exec("nohup curl --create-dirs -o {$write_path} {$source_url} > /dev/null 2> /dev/null & echo $!");
sleep(1);

$read_speed = 65.5; # 65.5 kb/s download rate
$handle = fopen($write_path, "rb");

$content_type = select_meta_item($headers, 'Content-Type');
$file_size = select_meta_item($headers, 'Content-Length');
send_headers($content_type, $file_size);
flush();

while (!feof($handle))
{
echo fread($handle, round($read_speed * 1024));
flush();
sleep(1);
}

fclose($handle);
Streaming an MP3 doesn't work using this method. Plays in Chrome, but not in Firefox. Initially I'll be using this to stream MP3 files through Long Tail's JW Player. If it all works out, I'll also be using this to send ZIP files

No comments posted yet

Your Answer:

Login to answer
142 Like 33 Dislike
Previous forums Next forums
Other forums

Calender Not Opening
The following code is not loading the javascript calender in another window. It's not doing anything

Transport data between itab and textfield on ALV event
Hallo,

I have a ALV Grid ( cl_gui_alv_grid ) and I also have hotspot click event with a h

Oracle Connectivity
Hi Every One,

Can we access SAP from oracle database.If it possible then please spec

animation progress while uploading files?
Hello, i have some website form to upload few files to server. i want to put some gif animation whi

search query in mysql in php problem
my search query wont work, i know, that my codes are correct.please help

Code: [Select]&l

php email checker
I am having alot of trouble finding info on how to do these email things. I need to do the following

noob question
i traying to do a php form with auto replay for both(me and the user who send me a mail),

a u

Parse Error Help
Hello, I got the parse error "Parse error: syntax error, unexpected ',' in register.php on line

Multi-image upload problems
Lets see if I can get some help on this one. Can anyone show me what I am doing wrong here. I'm just

How to file_get_contents when login required?
Hello!

I am trying to read data from a page that you have to be logged into to view, I am try

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash