NYCPHP Meetup

NYPHP.org

[nycphp-talk] Creating file for download on the fly?

sachin parekh parekhsj9 at hotmail.com
Fri Jul 26 10:47:25 EDT 2002


Hi Tom

nothing wrong in creating on the fly .cvs file if required only.
so you can save bulk of the .csv files.

anyway : two approach you can have

1: you can generate the file and save it to the harddisk  and offer as link.

2: You can either dont save it to disk but just output the content stream to 
the user when clickingon the link... by using
assuming "$contents" is the content that you want to write in a file.

header('Content-Type: application/text');
header('Content-Disposition: attachment; filename='.$FILENAME);
echo $contents ;
exit;


I hope this might be useful.

Sachin Parekh
Web Developer
India

>From: "Freedman, Tom S." <tfreedma at ubspw.com>
>Reply-To: talk at nyphp.org
>To: NYPHP Talk <talk at nyphp.org>
>Subject: [nycphp-talk] Creating file for download on the fly?
>Date: Fri, 26 Jul 2002 10:15:20 -0400
>Received: from mc2-f42.law16.hotmail.com ([65.54.237.49]) by 
>mc2-s1.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.4905); Fri, 26 Jul 
>2002 07:25:39 -0700
>Received: from slipdisc.virul.net ([66.114.66.188]) by 
>mc2-f42.law16.hotmail.com with Microsoft SMTPSVC(5.0.2195.4905); Fri, 26 
>Jul 2002 07:22:11 -0700
>Received: from nyphp.org (slipdisc.virul.net [66.114.66.188])by 
>slipdisc.virul.net (8.11.6/8.11.6) with ESMTP id g6QEFKP27753;Fri, 26 Jul 
>2002 10:15:20 -0400 (EDT)(envelope-from listmaster at nyphp.org)
>Message-Id: <200207261415.g6QEFKP27753 at slipdisc.virul.net>
>X-Paralist-Archived: 
><http://nyphp.org/list/paralist_archive.html?L_mid=834>
>X-List-Software: Paralist 0.6
>List-ID: <nyphptalk.nyphp.org>
>List-Owner: <mailto:listmaster at nyphp.org>
>List-Archive: <http://nyphp.org/list/paralist_archive.html?L_lid=1>
>List-Subscribe: <http://nyphp.org/list/>
>List-Unsubscribe: <http://nyphp.org/list/>
>Organization: New York PHP
>X-Mailer: Paramail 0.5
>Return-Path: listmaster at nyphp.org
>X-OriginalArrivalTime: 26 Jul 2002 14:22:12.0328 (UTC) 
>FILETIME=[D55BCE80:01C234AF]
>
>Hi all, I've been a lurker for a couple months as I've been learning PHP,
>and many of your suggestions have been really helpful.  I was hoping 
>someone
>might have an idea on how to tackle an issue I haven't been able to find 
>any
>info on.
>
>I'm currently working on a new version of a departmental intranet website.
>I have a database, and offer the users a search page that lets them query 
>it
>in a variety of ways.  The new results page is not laid out in a grid, as
>the old one was (we've added a lot of new fields, and the grid would be too
>packed).  Some users have requested the ability to download the data for
>import into Excel (they used to just copy and paste the table in).  I've
>figured out how to create a .csv file, and I could, theoretically, create
>one every time someone runs a query, save it in a temp directory, and
>include a link to it on the webpage.  We'd have to run a cleanup routine
>every night, though, to delete all these .csv's on the server.  It seems
>really clumsy to me.  What I'd like to do is put a link on the result page
>that, when clicked on, builds the .csv right then and offers it to the user
>for download.  Is this feasible, or should I just go with the temp 
>directory
>full of reports?
>
>Thanks in advance,
>Tom




_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com




More information about the talk mailing list