Welcome to WebmasterWorld Guest from 54.147.44.93

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

open a new file

open a new file

     

xbl01234

10:11 am on Jan 12, 2007 (gmt 0)

5+ Year Member



Hello;
I am trying to open a new file, but it give me the following massage, could anyone help, please.

Warning: fopen(testFile.php) [function.fopen]: failed to open stream: Permission denied in index.php on line 3
can't open file

<?php
$ourFileName = "testFile.php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fclose($ourFileHandle);
?>

omoutop

10:53 am on Jan 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



have you checked the folder permissions (where the file is)?

If they are set in a wrong way, php won't be able to create/open your file. Concult your manual for chmod() for start.

smells so good

11:10 am on Jan 12, 2007 (gmt 0)

5+ Year Member



Sure. The message you received is exactly what is coded into your php script. In fact, your php code is working perfectly. That's the good news. Now you need to set your file permissions. A little more info about the environment will be helpful. What OS are you running this script on?

xbl01234

11:21 am on Jan 12, 2007 (gmt 0)

5+ Year Member



Thanks for you both;

>What OS are you running this script on?
I am hosting now. I think the web server side use linux.

smells so good

11:32 am on Jan 12, 2007 (gmt 0)

5+ Year Member



You'll need to use chmod [us2.php.net], on the file and/or file directory. I was looking through the library [webmasterworld.com] for anything about permissions, but nothing stood out.

xbl01234

12:13 pm on Jan 12, 2007 (gmt 0)

5+ Year Member



But it is good to known i need to get a permission to open a new file.

i will try to find these information from google.

Thanks a lot

xbl01234

7:11 am on Jan 13, 2007 (gmt 0)

5+ Year Member



Hi smells so good,omoutop;
Thanks for you both advice, i can create a new file now.
Because i am hosting, so i go to set the permission for the file to 740.
Then it works.

but you think the value of 740 is enough safty?

 

Featured Threads

Hot Threads This Week

Hot Threads This Month