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

A Few Questions
Hi, I want to ask a few questions that I can't seem to find..

1) I'm creating a "shortcu

Is there something wrong?
Hi all,

Just a quick question... can someone look at this code and see if something is wrong?

need help with mail()
hi i want to send an email with attaching pdf file using php. i have the following script but the pr

Help with php code
Hello, can anyone tell me why this php word trap fails to work,
and the trigger words get blow r

Displaying a record from mysql in a simple swf file
Hi,

I have a mysql database containing information I would like to display in my swf.

SELECT * FROM users WHERE Users are not in Blocked
How do I select all users from users table where there users_id is not stored in the block table

IIS7 and getimagesize() problem
I have just discovered after hrs of trying to fix a problem where it's coming from. It's to do with

Load file in PHP
I have 2 files. The first is a PHP generated XML file that's dependent by 2 inputs. The second is a

I need some help with the IF command...
I have a large number of images in one section of my website with the .jpg format. I'm adding a bun

captcha error
I have been trying to implement a captcha in php...

here is the code..
Code: (php) [Select

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