NYCPHP Meetup

NYPHP.org

[nycphp-talk] need help regarding download bar

Tim Lieberman tim_lists at o2group.com
Tue Aug 7 17:25:10 EDT 2007


The headers I mentioned earlier are easy to send using PHP's header() 
function.

If I'm creating a large CSV file that I want the user to save to disk, 
and I want the browser to display meaningful download status, I'd do 
something like:

<?PHP
// $data contains a big string of comma-separated-value text
header('Content-type: text/csv');
header('Content-length: ' . strlen($data)); // if I was passing through 
some file on disk, i'd use filesize($someFile)
header('Content-disposition: attachment;filename="data.csv"');
echo $data
?>

For upload progress bars, swfupload, mentioned by Jon, works very well 
(usually).  There's a fork of it that does some extra useful stuff.  
Read about it here: http://linebyline.blogspot.com/index.html?rn=1150

-Tim

Jon Baer wrote:
> Upload is a different beast since you need to ping the server for stat ...
>
> Save yourself time + use this package (or something equivalent): 
>
> http://swfupload.mammon.se/
>
> - Jon
>
> On Aug 7, 2007, at 2:12 AM, birgunj birgunj wrote:
>
>> Dear,
>>
>>   Thanks alot for replying.if i want to upload file, will upload bar 
>> will show  in any browser  or i have to write script for showing 
>> upload bar?
>>
>>   humayoo
>>
>> Jon Baer <jonbaer at jonbaer.com <mailto:jonbaer at jonbaer.com>> wrote:
>>   There is already a download progress bar in every known browser last 
>> time I checked ;-) Why replicate?
>>
>> On Aug 6, 2007, at 3:24 PM, csnyder wrote:
>>
>>> On 8/6/07, birgunj birgunj wrote:
>>>> Dear All,
>>>>
>>>> i want to write script to download file.how do i display download 
>>>> bar in php
>>>> like when download file from any site, it download bar appear, it 
>>>> show
>>>> size of file,time etc.
>>>>
>>>> can any body help me how to do this.
>>>>
>>>> thanks humayoo
>>>
>>> Download is the responsibility of the client. This isn't in PHP's 
>>> domain.
>>>
>>> -- 
>>> Chris Snyder
>>> http://chxo.com/
>>> _______________________________________________
>>> New York PHP Community Talk Mailing List
>>> http://lists.nyphp.org/mailman/listinfo/talk
>>>
>>> NYPHPCon 2006 Presentations Online
>>> http://www.nyphpcon.com
>>>
>>> Show Your Participation in New York PHP
>>> http://www.nyphp.org/show_participation.php
>>
>> _______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>>
>>
>>
>> ---------------------------------
>> Shape Yahoo! in your own image.  Join our Network Research Panel 
>> today!_______________________________________________
>> New York PHP Community Talk Mailing List
>> http://lists.nyphp.org/mailman/listinfo/talk
>>
>> NYPHPCon 2006 Presentations Online
>> http://www.nyphpcon.com
>>
>> Show Your Participation in New York PHP
>> http://www.nyphp.org/show_participation.php
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php




More information about the talk mailing list