RE: Useful function for file download (i.e. MP3)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I don't know how to respond to this other than to apologize for
seeming like a smart-ass know-it-all.

I'm sorry.

On Tue, November 21, 2006 3:18 pm, Brad Fuller wrote:
>
> You might be interested to read the thread that was posted here:
>
> http://www.php.net/readfile
>
> There's a bit of discussion as to why the ob_flush() and flush() are
> in
> there.
>
> It's not my function. I don't take any credit for it, and frankly I
> don't
> care whether you think its useful or not, or whether you think parts
> of it
> are redundant, or if it can be done better; I just thought someone on
> this
> list who was working with file downloads might find it useful.
>
> I must admit I am a bit bothered by the fact that I can't submit
> something
> to this list without some smart ass know-it-all making some comments
> about
> how they could do it better.
>
> It almost makes me not want to contribute anything.
>
> -B
>
>> -----Original Message-----
>> From: Richard Lynch [mailto:ceo@xxxxxxxxx]
>> Sent: Tuesday, November 21, 2006 3:40 PM
>> To: Brad Fuller
>> Cc: php-general@xxxxxxxxxxxxx
>> Subject: RE:  Useful function for file download (i.e. MP3)
>>
>> On Tue, November 21, 2006 1:26 pm, Brad Fuller wrote:
>> >> I think it will use 1M...
>> >>
>> >> > function readfile_chunked($filename,$retbytes=true) {
>> >> >    $chunksize = 1*(1024*1024); // how many bytes per chunk
>> >>
>> >> :-)
>> >
>> > Yes 1M is what I meant, although you can set it to whatever you
>> want.
>> >
>> >> The multiple calls to ob_flush() within the body of the loop are
>> >> probably not a Good Idea, as a general rule...
>> >
>> > I think you missed the point of the function.
>>
>> I think not.
>>
>> I think you'd want to call ob_flush() in a loop at the top until
>> ob_get_level() returned 0, rather than rely on the number of
>> ob_handlers stacked up being smaller than the number of Megabytes to
>> be pumped out.
>>
>> That's assuming you would want to override any and all ob_start() in
>> the first place, which seems a decidedly odd way to structure a web
>> application to me.
>>
>> I would expect that your MP3 output URL would have already turned
>> OFF
>> output buffering in any php.ini type setting, and wouldn't have
>> started any output buffering up in the first place, since you
>> almost-for-sure knew from the very beginning of this request that
>> you
>> were outputting an MP3 file, which, by its very nature, you would
>> not
>> want to bufffer.
>>
>> >> flush() is also probably overkill, really, for any file big
>> enough
>> >> for
>> >> this function to be desirable in the first place...
>> >
>> > Php.net says "flush() has no effect on the buffering scheme of
>> your
>> > webserver or the browser on the client side. Thus you need to call
>> > both
>> > ob_flush() and flush() to flush the output buffers. "
>>
>> flush() is largely irrelevant to the HTTP interaction.
>>
>> TCP/IP, HTTP, Apache, etc all add buffers and network lag that
>> render
>> flush() meaningless in this context.
>>
>> Later versions of PHP, I think, pushed the boundary of flush() up
>> to/through the Apache layer of buffering.
>>
>> But they have zero effect on TCP/IP stack, much less any sort of
>> other
>> client-server buffering.
>>
>> --
>> Some people have a "gift" link here.
>> Know what I want?
>> I want you to buy a CD from some starving artist.
>> http://cdbaby.com/browse/from/lynch
>> Yeah, I get a buck. So?
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some starving artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux