Jump to content

Recommended Posts

You can pass string data using the $_GET array by attaching the string to the URL; or by using the $_POST (or $_GET) array via a form submission using the post (or get) method; or by setting the string as a session value and recovering it in the next script; or by creating a cookie containing the string and recovering it in the next script.

Does any of that have anything to do with what you're hoping to do?
Link to comment
https://forums.phpfreaks.com/topic/11115-output-string-as-file/#findComment-41558
Share on other sites

No not really. Maybe I can clarify what I meant. I have a page where a user submits data into a textarea. I take that input and apply some regular expressions to it so that i can extract certain information. I then want to take the information that I am extracting and create an xml file from that. I have the code already built where php fills in all the blanks between my elements and sends it to the broswers as a regular php/html file. If you view the page source of the php output in the web browser you can see all the xml elements. I just want to take those elements into a file , xml, and when the script is used you are prompted for an xml file download or you are passed a xml file not a php file. I also don't want to create any files on the server, if I wanted to do that I would not be asking for help since that i do know how to do!. Thanks
Link to comment
https://forums.phpfreaks.com/topic/11115-output-string-as-file/#findComment-41569
Share on other sites

Found the answer to my own question. Thanks to all who looked.

header('Content-type: application/xml'); <- insert whatever application type you are trying to send
header('Content-Disposition: attachment; filename="download.xml"'); <- filename = whatever you want

any content that your script would send to the browser after the header will be sent to the browser as a file to be downloaded.
Link to comment
https://forums.phpfreaks.com/topic/11115-output-string-as-file/#findComment-41604
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.