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

why is it over writing
Code: $filepaths[] = $_FILES['new_image'];
foreach ($filepaths as $filepath)
{
$imagename =

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

Show message after entering data
Hello Colleagues

I would like to display messages after entering the data example: "
dat

Add trigger to UpdatePanel programmatically
Hi,I'm working on a website which uses AJAX and Masterpages. What I have is an AJAX UpdatePanel whi

Showing selected item at top of list
Hi,

I've got a list of names which i am fetching from database like this:
$qry = db_query

Php navigation
I have four buttons on a php page.
If i click a button it will redirect to different php pages.

Help with page encoding issue and weird characters
I'm trying to write a screen scraper and when I pull out the lines of the html file that I'm interes

Structure Question - One Table or One Table Per Record Set?
I have a web app (mySQL and PHP) which allows people to create an item with up to 200 records which

Values disappear from my array :( HELP!
hey all, I have a lil mysql/php/apache script that queries a database
and pulls put 5 integers.

want to add a break after a certain amount of characters
i was wondering how to add a break in a blog post after a certain amount of characters... any idea o

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