# \[PHP\] Using touch() to create a file

**URL:** <https://forum.kirupa.com/t/php-using-touch-to-create-a-file/79399>\
**Category:** programming\
**Created:** [February 13, 2005, 9:16pm UTC](https://forum.kirupa.com/t/php-using-touch-to-create-a-file/79399 "2005-02-13T21:16:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw06](https://avatars.discourse-cdn.com/v4/letter/j/838e76/32.png) [@jw06](https://forum.kirupa.com/u/jw06)\
**Post date:** [February 13, 2005, 9:16pm UTC](https://forum.kirupa.com/t/php-using-touch-to-create-a-file/79399/1 "2005-02-13T21:16:59Z")

</div>

I’m trying to create a file when I add a new entry to my MySQL Database, but I keep getting this error:

Warning: unable to create file /home/portfolio/www/portfolio/102984.php because Permission denied in /home/portfolio/www/admin/admin\_portfolio.php on line 49

I have chown’d both directories (admin & portfolio), but it still isnt allowing me to create the file. Any idea on what I can do?

Code:

```php

		$filename = $_POST['link']; 
		if (!file_exists($_SERVER['DOCUMENT_ROOT'].'/portfolio/' . $filename)) { 
 		 touch ($_SERVER['DOCUMENT_ROOT'].'/portfolio/' . $filename);
		} 

```
