Can I ask what should I check..? I am sorry that I have little experience in config. the webserver..
Main Topics
Browse All TopicsHi all,
here is the code for generating file thru php:
$filename="testing.txt";
$file=fopen($filename,"w")
fwrite($file, "Hello\n");
fclose($file);
but I usually get this warning :
Warning: fopen(testing.txt): failed to open stream: Permission denied
the code is ok if the file is already there, (i.e. overwrite or append to a existing file is ok)..so how can I create a new file thru php? please advise.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
It's probably only the webserver that needs access to write to this folder, so 777 could be too much.
How about creating a sub folder called personalFiles or something and write your files there.
On your server, go to the folder where your scripts are, then create a sub folder like this:
mkdir personalFiles
Then change ownership of that folder
chown nobody personalFiles
I assume that your webserver is user "nobody"
Then change the the rights to this folder
chmod 755 personalFiles
now you should be able to create files in this folder with the following script:
$filename="personalFiles/t
$file=fopen($filename,"w")
fwrite($file, "Hello\n");
fclose($file);
ping1234,
As Batalf mentioned, you should create a subdirectory whereto you want to save your files. However, when you are on a commercial hosting server you might not have commandline/ssh access.
Nontheless, you can often perform this task using your own FTP-program.
You'll run your client and create a directory on the webspace, where you want to store your files.
Then you right-click on the directoryname and select the option which could be: "chmod"/"chmod (UNIX)" or just plain "properties".
Depending on your server user properties you have to choose either 755 or 777 configuration or check the boxes such that you create:
Owner: Read:Yes, Write:Yes, Execute:Yes
Group: Read:Yes, Write:Yes, Execute: Yes/No (755 = No, 777 = yes, try No first)
Other: Read:Yes, Write:Yes, Execute: Yes/No (755 = No, 777 = yes, try No first)
-r-
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.
I will leave the following recommendation for this question in the Cleanup topic area:
Accept: Batalf
Any objections should be posted here in the next 4 days. After that time, the question will be closed.
Huji
EE Cleanup Volunteer
Business Accounts
Answer for Membership
by: BatalfPosted on 2005-05-19 at 02:01:07ID: 14034479
There's nothing wrong with your code, so it looks like the webserver doesn't have access to create new files in this directory. The first you should do is to check these permissions.
Batalf