downloading variable data

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

meone
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Jun 23, 2003 11:30 am

downloading variable data

Postby meone » Mon Jun 23, 2003 12:04 pm

This might be a stupid question but i was wondering if it was possible with php to take the data from a variable and have a user download it as a file. I know that i could make a file and write the data to it. Then have them download that file and then erase the file when it is done. But i was wondering if there is a way to skip those steps? thanks for your help

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Tue Jun 24, 2003 11:54 pm

it is very possible to do that.

Before you echo anything out to the browser you will have to send a header call with the file type.

lookup http://www.php.net/header

Code: Select all

header("Cache-control: private");
header("Content-type: application/zip");
header("Content-disposition:attachment; filename=$filename");

meone
New php-forum User
New php-forum User
Posts: 2
Joined: Mon Jun 23, 2003 11:30 am

Postby meone » Wed Jun 25, 2003 11:04 am

thanks for the help


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron