Building a plugin, can't send header()
-
Ok, i’m building a plugin that posts some stuff to a table. The admins can see the answers in a table, and i’m trying to make a “download data to XML”-function.
The plugin creates a menu option and the table with answers is displayed in the wpwrap div. There fore, i can’t do this the traditional way with
header('Content-type: text/plain'); header('Content-disposition: attachment; filename="MyXML.xml"'); /* echo the content as XML */
since headers has been sent. I have a function that generates a string with correct formatted XML, how can i now send this string as a file to the admins browser for download?
I would prefer not to store the file physically on the server for downloading.In short, it works like this;
The “Generate XML”-button is in a small form, it posts this command (‘do’) along with the id number of the table i want to get data from. In the top of this file, i check for $_POST[‘do’] and checks if its set to ‘XML’. In chat case it generates the string, and the problem i have from there is to send it as a downloadable file to the browser.Any suggestions?
- The topic ‘Building a plugin, can't send header()’ is closed to new replies.