# Control Growing Files

**URL:** https://forum.kirupa.com/t/control-growing-files/254028
**Category:** programming
**Created:** [March 7, 2008, 11:21am UTC](https://forum.kirupa.com/t/control-growing-files/254028 "2008-03-07T11:21:33Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Largo](https://avatars.discourse-cdn.com/v4/letter/l/41988e/32.png) [@Largo](https://forum.kirupa.com/u/Largo)
#### Post date: [March 7, 2008, 11:21am UTC](https://forum.kirupa.com/t/control-growing-files/254028/1 "2008-03-07T11:21:33Z")

</div>

Hi, here is my situation. I have an online flash game that tracks some data from the users.  
Here’s how it works: Flash sends data to PHP and PHP writes that data to an XML file.  
**What would be the best way to make sure that the XML’s filesize doesn’t grow too big?**  
Can I add some code to the PHP that checks the XML’s filesize and creates a new XML file if it gets too big?  
I don’t know PHP that well so I need some help. I know that I could just do this by hand regularly on the server, but I want to know if there is some way to automate this process, so if there is any other way please let me know. 🙂

This is my simple PHP code, that writes the flash data to PHP:

```php
 
<?php
$filename = "xmldata/trackingData.xml";
$raw_xml = file_get_contents("php://input");
 
print $raw_xml;
 
$fp = fopen($filename, "w");
fwrite($fp, $raw_xml);
fclose($fp);
?>

```
