ohdang888 Posted December 24, 2007 Share Posted December 24, 2007 heres my code to automatically create a folder and a index.php in it: but one problem, i'm getting an error of:? Warning: mkdir() [function.mkdir]: Permission denied in C:\xampp\htdocs\create\index.php on line 13 p.s.- i'm eventually going to add a template where it would add this info in certain specified sections of the page <html> <form method="post"> Name of game:<input type="text" size="15" maxlength="30" name="name"/> <br/> folder name:<input type="text" size="15" maxlength="30" name="folder"/> <input type="submit" name="submit" value="Submit"/> <?php $name = $_POST["name"]; $folder= $_POST["folder"]; mkdir("/$folder", 0700);// this creates the directory, but i think my permissions are messed up $newindex = "index.php"; $fh1 = fopen($newindex, 'w') or die("can't create file"); fwrite($fh1,$name); fclose($fh1); ?> Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/ Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 the html code is right in the real thing (the < and >are messed up in the example) Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/#findComment-422201 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 so how do i change my permissions, i know its in htaccess but i can't figure it out and all the google searchs aren't coming up with anything understandable... any1 got any links? Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/#findComment-422202 Share on other sites More sharing options...
cooldude832 Posted December 24, 2007 Share Posted December 24, 2007 well lets first talk problems first your $folder is an issue you are taking raw post data into it, user could put ./ or ../ and get above where they suppose to. Secondly you don't define a context for the folder, doing so eliminates the above problem $_SERVER['DOCUMENTS_ROOT']."/Content/"; for example will save you injection Now issues you don't ave premission because that folder you are making the folder needs to have the outside world have write access to check that. Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/#findComment-422205 Share on other sites More sharing options...
ohdang888 Posted December 24, 2007 Author Share Posted December 24, 2007 whats a context for the folder????? only i will be using this tool, its just to save me time. so i don't nee dto wrorry about others using this, it will be restricted to all others.... so i don;t need to think about the 2nd part? right? Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/#findComment-422206 Share on other sites More sharing options...
cooldude832 Posted December 24, 2007 Share Posted December 24, 2007 whats a context for the folder????? only i will be using this tool, its just to save me time. so i don't nee dto wrorry about others using this, it will be restricted to all others.... so i don;t need to think about the 2nd part? right? The purpose to asking for help is not to solve this one problem but to prevent future if you make the mistake now you will surely make it in the future. You should always verify user input even if its yours by some system. But you real issue is that folder doesn't have premissions set right Quote Link to comment https://forums.phpfreaks.com/topic/83011-automatically-create-pages/#findComment-422211 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.