# Create file and force download

**URL:** <https://forum.kirupa.com/t/create-file-and-force-download/315634>\
**Category:** Uncategorized\
**Created:** [October 31, 2010, 12:29am UTC](https://forum.kirupa.com/t/create-file-and-force-download/315634 "2010-10-31T00:29:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![darroosh](https://avatars.discourse-cdn.com/v4/letter/d/a88e4f/32.png) [@darroosh](https://forum.kirupa.com/u/darroosh)\
**Post date:** [October 31, 2010, 12:29am UTC](https://forum.kirupa.com/t/create-file-and-force-download/315634/1 "2010-10-31T00:29:31Z")

</div>

I want to create an xml sitemap , I made a php script that creates it … but the created xml code is saved inside a variable named as $xml

Now I want this variable to be saved inside a file named as sitemap.xml and force the browser to download it , Any help ?

Thanks fro any trial to help.  
Dr Mostafa
