# Php - How to NOT Overwrite a File?

**URL:** <https://forum.kirupa.com/t/php-how-to-not-overwrite-a-file/302821>\
**Category:** Uncategorized\
**Created:** [January 8, 2010, 12:59am UTC](https://forum.kirupa.com/t/php-how-to-not-overwrite-a-file/302821 "2010-01-08T00:59:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jebego](https://avatars.discourse-cdn.com/v4/letter/j/e480ec/32.png) [@jebego](https://forum.kirupa.com/u/jebego)\
**Post date:** [January 8, 2010, 12:59am UTC](https://forum.kirupa.com/t/php-how-to-not-overwrite-a-file/302821/1 "2010-01-08T00:59:53Z")

</div>

This is my current php script

```php

$fp = fopen('image.jpeg', 'wb');
fwrite($fp, $GLOBALS['HTTP_RAW_POST_DATA']);
fclose($fp);

```

I’m using my flash file to send some data to my php file to create and save a .jpeg on my server under the name of “image.jpeg”.

If I want to create more the one image, this script overwrites my current image.

How would I not overwrite it, but instead add a number to the end of the image’s name, ex: image.jpeg, image-2.jpeg, image-3.jpeg, you get the point.

This is probobly pretty simple, I’m just somewhat of a noobie at php.

Thanks!
