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

Page not Loading After Test
Hey All

It seemed that an inlcude statement wasn't working for some reason, so I tried a more

Help on query replacing the date
Hi Pals,

i want to replace the current date in a column to some value say C or D or any n

mail() problem
Hi Guys,

I've set up a contact email form. It sends the information fine, but it sends it to

Splitting Attributes
SQL> SELECT I_NAME, substr(I_NAME,1,instr(I_NAME,'O')) "First part",

substr(I_NAME, IN

Drawing Images in classes
I'm quite new to Object Oriented PHP. What I'm trying to do is draw some images but also have other

utl_file open error
i have file in the unix path

Path /popdev01/pop/popdevb/tfi/

File name

displaying email without attracting a ton of spam
Hello,

this is maybe the wrong place to ask.
How would you display an email address on a w

Problem with an browser game.
Hello,i just joined that great forum and i got php prob,its kinda freaky...anyway i got browser game

Oracle Connectivity
Hi Every One,

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

help with email script...
hey

I need help with my mail script

when the form on http://www.mcgdesignstudio.com/c

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