# I can not create files in FreeBSD using PHP?



## anti (Feb 14, 2010)

hi

i wrote this code in php but there is no effect??





when i try to read the content of file it work fine but when i try to write it can not!

any ideas?


----------



## volatilevoid (Feb 14, 2010)

Most likely, the process executing your PHP script doesn't have the right permissions needed to modify the file.

Do you run your script inside a browser? Where is the file you want to modify?


----------



## anti (Feb 14, 2010)

my file locates in /usr/local/www/apache22/data/t

how can i change permissions?? to what??

i run my script inside same previous path using internet explorer in another machine


----------



## volatilevoid (Feb 14, 2010)

Try `# chown www:www /usr/local/www/apache22/data/t`. This changes the owner of the given directory to the user and group of the web server.

And don't forget to do

```
fclose($handle);
```
after you wrote to the file.


----------



## FBSDin20Steps (Feb 14, 2010)

volatilevoid said:
			
		

> Try `# chown www:www /usr/local/www/apache22/data/t`


. This changes the owner of the given directory to the user and group of the web server.

It can also be...


```
# chown -R www:www /usr/local/www/apache22/data/t
```


----------



## SirDice (Feb 15, 2010)

To save yourself from a world of problems, don't ever write files in the same directory as the web application.


----------



## anti (Feb 15, 2010)

alot of thanx guys

the problem was in permission of files not directory!!


----------

