Re: downloading text files stored in database?
| From: | Ivan Balazs | Date: | Mon, 25 Feb 2002 21:54:15 +0000 |
| Subject: | Re: downloading text files stored in database? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-86162@lists.php.net to get a copy of this message | ||
In the download_file.php put a header() function which redirects the
browser to the file, like header("Location: test.dat"). After that it
should show the dialog screen.
Balazs
On Mon, 25 Feb 2002, Lee P Reilly wrote:
> Hi,
>
> I wonder if someone can point me in the direction of an example and / or
> some documentation for the following task:
>
> I have a DB table containing the name and contents of plain text files
> that users have uploaded. I have a facility which allows users to view
> these, but I would also like the users to be able to *download* these
> files (i.e. display an 'open from present location / save to disk'
> dialogue). I am thinking that this would be accomplished by including a
> few META data lines at the top of a .php script, but would this allow
> me to specify the default saved name?
>
> e.g. there is record in the DB for a file called "test.dat". I have a
> form that will submit to something like download_file.php, which will
> then (given the file id) obtain the appropriate data from the database
> and prompt the user whether they wish to open the file or save it (this
> will be the built-in dialogue with the browser). On selecting the save
> option, the default file name will appear as "test.dat" as opposed to
> download_file.php.
>
> Any information would be greatly appreciated. Thank very much in
> advance.
>