macattack Posted May 17, 2008 Share Posted May 17, 2008 I have the following code, if($_POST['save'] == 'Save'){ if(!is_dir(DIRECTORY_LISTING.'/'.$_POST['dir'])){ mkdir(DIRECTORY_LISTING.'/'.$_POST['dir'], 0777, true); } $fp = fopen(DIRECTORY_LISTING.'/'.$_POST['blog'], 'w'); fwrite($fp, $_POST['content']); fclose($fp); echo "Blog entry saved/updated<br><br>"; } which references the following function: function displayAddNewBlogForm(){ echo "<a href='index.php'>".BLOG_NAME."'s Editor Home</a><br>"; $monthWritten = date("F"); $month = date("m"); $day = date("d"); $year = date("Y"); $hour = date("H"); $minute = date("i"); $name = $_POST['title']; echo "<p1>Add new blog entry for $day $monthWritten, $year $hour:$minute"; if(is_file(DIRECTORY_LISTING."/$year/$month/$day/$hour $minute")){ echo "You've already created a blog entry in the last minute. Try deleting it or editing it instead!"; } echo "<form action='index.php' method='POST'>"; echo "<input type='hidden' name='blog' value='$year/$month/$day/$name'>"; echo "<input type='hidden' name='dir' value='$year/$month/$day/'>"; echo "<label for='title'>Post Title</label><input type='text' name='title'><br>"; echo "<textarea name='content' cols='100' rows='15'>Write your post here</textarea><br>"; echo "<input type='submit' name='save' value='Save'> "; echo "</form>"; } When I try to save the post, I get the following message: "Warning: mkdir() [function.mkdir]: Permission denied in /Users/username/Sites/PHP Blog/edit/index.php on line 9" I don't know if it makes a difference, but I am running OS 10.5.2 Thanks in advance for any help. Quote Link to comment Share on other sites More sharing options...
nloding Posted May 17, 2008 Share Posted May 17, 2008 Not a PHP problem, I don't think. I'm going to be that it's as simple as the directory permissions on your wwwroot. If it's a *Nix box: chmod 777 /path/to/root/dir. Depending on how you created the files, you may not be the owner and thus may not be able to modify the files. In which case, you'd need to do chown. When you say "OS 10..." does that mean a Mac? In which case, I know nothing about them and may have typed all that in vain. Quote Link to comment Share on other sites More sharing options...
mlin Posted May 17, 2008 Share Posted May 17, 2008 apache runs as it's own user by default. If you own the directory, but apache tries to write to it, it will be denied. You can either chmod 777 or you can check your httpd.conf file to check/change apache's user/group values. If you change your conf, remember to restart your server before testing. Quote Link to comment Share on other sites More sharing options...
macattack Posted May 17, 2008 Author Share Posted May 17, 2008 I'm not aware of how to do this chmod operation. I did a quick check on Google, but I guess my knowledge isn't that great. And yes, 10.5.2 is the latest Mac OS. If someone has another suggestion and/or can explain a little more about how to make this change, that'd be wonderful. Quote Link to comment Share on other sites More sharing options...
corbin Posted May 17, 2008 Share Posted May 17, 2008 Errrr you could try opening terminal and running it. I don't use Mac, nor have I ever for anything not Internet related (friend has a Mac)... so... no idea. Just a suggestion ;p. Quote Link to comment Share on other sites More sharing options...
nloding Posted May 18, 2008 Share Posted May 18, 2008 http://developer.apple.com/documentation/Darwin/Reference/ManPages/man1/chmod.1.html Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.