You are here: Re: Is there a way to redirect to a page that doesn't exit? « All PHP « IT news, forums, messages
Re: Is there a way to redirect to a page that doesn't exit?

Posted by Janwillem Borleffs on 10/10/21 11:24

Mark C wrote:
> I admit the subject is a bit of an oxymoron. Here is what I want to
> do:
>
> I want to build a CSV file in a variable and then redirect the
> browser to the contents of the variable so the user can download the
> "file" or open it in Excel. I don't want to create a real file so I
> can avoid cleaning up files after they are used.
>
> Is there a way to do this? I'm using Php on Linux.
>

Just redirect to a file which gathers the data and sends the apprioriate
headers to the browser to trigger the download dialogue.

Example:

// download.php
<?php

// Headers to start the download; note that a timestamp is used
// as the file name to prevent caching
header('Content-Type: x-download');
header('Content-Disposition: attachment; filename="' . time() . '.csv"');

// Construct and echo the data here

?>


JW

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация