Jump to content

fopen() permission problem


moose4204l

Recommended Posts

I am creating a PHP page where I need to create a file, the snippet code i am using is

$fp = fopen("$DOCUMENT_ROOT/../Adirectory/Afile.txt", 'w' )

 

but when i run the page, i get a permissions problem. then I chmod'ed the folder to 755 and it didnt work, then I chmod'ed it to 777 and it worked. However, my question is, is this the real way to do it or does that have a security risk involved? Is there a different way I should be doing this?

Link to comment
https://forums.phpfreaks.com/topic/157446-fopen-permission-problem/
Share on other sites

I think you could do somthing like this:

 

chmod("$DOCUMENT_ROOT/../Adirectory/", 7777);
$fp = fopen("$DOCUMENT_ROOT/../Adirectory/Afile.txt", 'w' )
chmod("$DOCUMENT_ROOT/../Adirectory/", 0755);

 

Hit up http://us.php.net/chmod for more information about it.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.