Hi,
I have a button that's uploading a CSV file to the user when it's pressed. The user can save the file, but there is a problem when opening it: the file contains the whole html page, including my CSV data. I'm trying to figure why.
Here's a rough outline of my code. My index.php looks like this:
ob_start();
// html stuff
if ($_POST[csv_button]) generate_csv();
ob_end_flush();
In my index.php, I also defined the generate_csv function:
ob_start();
// print mime header
// generate csv data
ob_end_flush();
Do I really need to create a separate php file to do the file transfer? I know this method works. Everybody seems to be doing that. I'd really like to know if I can embed this task into an existing file rather than creating a new one.
All help is welcome!