Thoth2020 Posted September 30, 2006 Share Posted September 30, 2006 I am trying to create a page with newspost functionality, wherein the user can type a subject and body, and it will be put at the top of a news.php page which is included in another index.php page. I was getting permission denied errors, so I thought I would use chmod(), but I am getting the following errors.[code]Please wait...Warning: chmod(): Operation not permitted in /Sites/Tear Gas Media/dopost.php on line 9This is a test to see if my news include idea actually works.Warning: fopen(news.php): failed to open stream: Permission denied in /Sites/Tear Gas Media/dopost.php on line 9Warning: fwrite(): supplied argument is not a valid stream resource in /Sites/Tear Gas Media/dopost.php on line 10[/code]I am running Apache on Mac OS X 10.3.9, and safe mode is off.Here is the code of the page that is supposed to execute the actual posting:[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?phpecho "Please wait...";$day = getdate(date("U"));$old = file_get_contents("news.php");chmod("news.php","0777");echo $old;$file = fopen("news.php","w+");fwrite($file,"$day[month] $day[mday]" . "\n" . $_POST["subject"] . "\n" . $_POST["news"] . "\n" . $old);?></body></html>[/code]I guess, basically, my question is, why can't I access this file, given that safe mode is off? chmod doesn't want to work, dangitall, and that's causing the other errors. Link to comment https://forums.phpfreaks.com/topic/22556-using-php-to-modify-a-file-getting-errors/ Share on other sites More sharing options...
michaellunsford Posted September 30, 2006 Share Posted September 30, 2006 Have you made sure the file that's running has the same owner as the file you're trying to chmod. Link to comment https://forums.phpfreaks.com/topic/22556-using-php-to-modify-a-file-getting-errors/#findComment-101232 Share on other sites More sharing options...
Thoth2020 Posted September 30, 2006 Author Share Posted September 30, 2006 Yes, both files have the same owner. Link to comment https://forums.phpfreaks.com/topic/22556-using-php-to-modify-a-file-getting-errors/#findComment-101267 Share on other sites More sharing options...
michaellunsford Posted September 30, 2006 Share Posted September 30, 2006 try the 0777 without quotes. Link to comment https://forums.phpfreaks.com/topic/22556-using-php-to-modify-a-file-getting-errors/#findComment-101414 Share on other sites More sharing options...
Thoth2020 Posted October 1, 2006 Author Share Posted October 1, 2006 Removing the quotes resulted in the same error "Warning: chmod(): Operation not permitted in /Users/tedpolak/Sites/Tear Gas Media/dopost.php on line 9" Link to comment https://forums.phpfreaks.com/topic/22556-using-php-to-modify-a-file-getting-errors/#findComment-101674 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.