I want to create a file on-the-fly and send it to the browser instead of the php site. I think I need to use the Header-Function, but how do I do that? Can anyone tell me that?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you need to make some data to be downloaded as regular file then you need to say to Browser that the content you gonna send must be downloaded instead as displayed on the browser as a regular HTML. To to do that you can use the header.
For example: if you need to get a .csv file dinamicly generated by PHP then you need to insert this lines of code before display any data on the page:
Make sure you don’t send any data to browser before setting any header parameter.