josephman1988 Posted August 25, 2008 Share Posted August 25, 2008 Ok guys, I have a form that uploads aload of data to a mysql db aswell as uploading an image to an already created image folder. Now i have added some script that takes the title of the inputted form, turns it into a user friendly url, which then attempts to create a folder with this name. However executing this form returns the following error. Error: mkdir() [function.mkdir]: Permission denied in Using this PHP code. PHP code: $titlereplace = "/"; $titlereplace .= str_replace(' ', '-', $gTitle); $titlereplace .= "/"; $makedir = mkdir("$titlereplace", 0777); What am i doing wrong? Hope someone can help. Link to comment https://forums.phpfreaks.com/topic/121303-mkdir-permission-issue/ Share on other sites More sharing options...
BlueSkyIS Posted August 25, 2008 Share Posted August 25, 2008 mkdir requires that the directory created be within the directory in which the script runs. /anything is not in the script's path (unless you are running your scripts in /, which would be a horrible idea.) Chances are, you need to append the script's directory to the front of your directory name, or use __FILE__ and similar constants to get it. example, assuming your script is running in DOCUMENT_ROOT (www.yourdomain.com/script_is_here.php): $titlereplace = $_SERVER['DOCUMENT_ROOT'].'/'; $titlereplace .= str_replace(' ', '-', $gTitle); $titlereplace .= '/'; $makedir = mkdir("$titlereplace", 0777); Link to comment https://forums.phpfreaks.com/topic/121303-mkdir-permission-issue/#findComment-625389 Share on other sites More sharing options...
josephman1988 Posted August 26, 2008 Author Share Posted August 26, 2008 Thanks, that did solve the problem =] However, although the directory is being created, via ftp anyway, you can't put anything in it due to not having enough permission, also not being able to change the permissions themselves. Why is this? the permissions stick on 0755. Also an additional question, how am I able to place a template withing the folder upon upload and creation of the directory. EG, upon creation and submission of the form, my 'details.php' template page is placed inside as each form submission will create a new page also: /title1/details.php?id=1 ^^^^ newly created directory /title2/details.php?id=2 ------^^^^^^^^^^ ------template placed into directory and id calling relevant informartion from that form Thanks for any help. Link to comment https://forums.phpfreaks.com/topic/121303-mkdir-permission-issue/#findComment-626363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.