Re: Dynamic generation of text files?

From: Date: Mon, 19 Mar 2001 14:58:22 +0000
Subject: Re: Dynamic generation of text files?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-44555@lists.php.net to get a copy of this message
<a href="/scripts/GenericCard.php?uid=UniqueUserKey">Click here for John Doe's vCard</a> GenericCard.php would have something like... // // build $text from $uid passed in // header("Content-type: x/y"); header("Content-Disposition: attachment; filename=$filename" ); print $text; exit(); "x/y" would be something like text/html or application/vnd.excel or something like that. Whatever the defined MIME header for Vcards is, put that after the content-type. $filename would be the name of the file you want to call this - something.vcf I'd expect. We do this with Excel files all the time - sending down tab-delimited text, and putting an excel application header on the file. Dan Costello wrote: > Hi, > > I'm trying to get my site to generate text files with a certain extension > and MIME-type from a database, "on the fly". > > Specifically, I would like to build something that can create vCards, that > is, text files of a particular format with the extension *.vcf, mime-type > text/x-vcard, _at the time that the user clicks the link to download the > file_. > > Currently, the only way I have of doing this is prebuilding all the vcf > files when the page is built, then deleting them when the user goes > somewhere else -- pretty inefficient. I'd really like to have, e.g. a bunch > of links that look like this: > > <a href="/scripts/GenericCard.vcf?uid=UniqueUserKey">Click here for John > Doe's vCard</a> > > ...so that when the user clicks the link, their contact manager (Outlook, or > whatever) fires up on their machine and displays the freshly-generated > vCard. > > I have, of course, thought of modifying the httpd.conf to have apache parse > files with a .vcf extension through the php interpreter -- I think that this > would be a very bad idea. ;-) > > So, is this too much to hope for?

« previous php.general (#44555) next »