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

142 Like 33 Dislike
Previous php-forum Next php-forum
Other php-forum

Getting PHP to ammended the selected in option field
Hey Guys

thanks for everyones help so far. This site and its users are oozing awesomness.

Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha

New Search Engine problem
Hey everyone,

I have a ZIP Code Radius search engine already functional. it displays all of t

Convert Binary String to Decimal
Trying to Get:
Decimal: 305419896

Out of:
Binary String: xV4

Strange HTML Tag?
I recently noticed some odd HTML appear in some of the websites I host. Not all of them are run on a

How do I replace any number of character occurences with one occurrence?
How do I replace any number of character occurences with one occurrence?

Let's say I have:

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

PHP mail() returns true but doesn't work
First off I apologize if this is a newbie question, and I generally don't like asking questions that

How to get variable value on next page
Hello friends
i am working on payentry page ..there i have this code.........

Passing Variables
What I'm wanting to do is when the user clicks on Arenas it will know the name of the country it's w

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