homepage Welcome to WebmasterWorld Guest from 54.197.65.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
open a new file
open a new file
xbl01234

5+ Year Member



 
Msg#: 3217075 posted 10:11 am on Jan 12, 2007 (gmt 0)

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

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3217075 posted 10:53 am on Jan 12, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3217075 posted 11:10 am on Jan 12, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3217075 posted 11:21 am on Jan 12, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3217075 posted 11:32 am on Jan 12, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3217075 posted 12:13 pm on Jan 12, 2007 (gmt 0)

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

5+ Year Member



 
Msg#: 3217075 posted 7:11 am on Jan 13, 2007 (gmt 0)

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?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved