wmguk Posted March 28, 2008 Share Posted March 28, 2008 $login = $_GET['login']; $filelocation = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients"; $mkdir = "$filelocation/$login"; mkdir("$mkdir"); chmod("$mkdir", 0777); I'm trying to get it to make http://www.mmmmmm.co.uk/clients/123 so i use createfile.php?login=123 but it just will not work. any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/ Share on other sites More sharing options...
Cep Posted March 28, 2008 Share Posted March 28, 2008 I would test to see if mkdir is creating the folder. As mkdir will return a result you can do this, <?php $success = mkdir($mkdir); if ($success===true) { echo "Directory succeeded"; } else{ echo "Directory failed"; } ?> By the way you do not need to surround the variable $mkdir in quotes. Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502924 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 I get directory failed... any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502955 Share on other sites More sharing options...
ansarka Posted March 28, 2008 Share Posted March 28, 2008 you may not have permission to create the folders chk the permission of folder httpdocs and clients Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502956 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 the folder clients is 777 this is an edited tidy version of my script //connection.php //FTP ACCESS SETTINGS - createadmin/uploadim.php $filelocation = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients/$login"; $ftpuser = "ftpuserxxx"; $ftppass = "xxx"; $ftplocation = "ftp.mmmmmm.co.uk/httpdocs/clients"; $ftpacc = "ftp://$ftpuser:$ftppass@$ftplocation/$login" ; $login = $_GET['login']; include "../scripts/connection.php"; mkdir($filelocation, 0777); Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502959 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 also i echo the different variables and they are displaying correctly, so any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502960 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 this has got me totally stumped Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502971 Share on other sites More sharing options...
Cep Posted March 28, 2008 Share Posted March 28, 2008 if mkdir() is returning failed its most likely because you do not have permission to create folders. What is the permission level of the parent or root directory? Does it allow anonymous creations of directories (I doubt it). Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503005 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 if i use this script $thisdir = getcwd(); if(mkdir($thisdir ."/$login" , 0755)) { echo "Directory has been created successfully... $thisdir "; } else { echo "Failed to create directory... $thisdir"; } it works, the only issue is that it making the folder in the wrong directory, it needs to be in clients, so i edit the script $thisdir = "/var/www/vhosts/mmmmmm.co.uk/httpdocs/clients"; if(mkdir($thisdir ."/$login" , 0755)) { echo "Directory has been created successfully... $thisdir "; } else { echo "Failed to create directory... $thisdir"; } and it fails. the location of the script is https://www.mmmmmm.co.uk/createadmin/ and it needs to create a folder at http://www.mmmmmm.co.uk/clients/ I have set the whole root folder as 777 and the clients folder is 777 too. would this have anything to do with the script being on an SSL server and trying to create a folder somewhere else? (obviously mmmmmm.co.uk is not the real domain) Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503122 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 You should never have to chmod your webroot at 777, unless you are modifying files in it. Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503131 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 yeah, ive put it back now, i just wanted to rule it out Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503138 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 not that its a big security risk or anything (assuming your usr folder isn't 777). It's just good practice to only chmod 777 the directories you need to. As far as your problem goes, you may want to contact your host. Try is one out <?php $dir = $_SERVER['DOCUMENT_ROOT'] . 'phpfreaks_help/newfolder/'; if (is_dir($dir) ) exit($dir .' is already made'); if (!chmod(pathinfo($dir, PATHINFO_DIRNAME), 0777) ) echo '<b>Warning: </b> Could not CHMOD parent folder. If you are on a Windows server, please ignore<br>'; if (!mkdir($dir, 0777) ) exit('Failed to make '. $dir .' at CHMOD 0777'); if (is_dir($dir) ) exit($dir .' made successfully'); ?> Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503159 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 ah ha, okies managed to get it to work, however can i get it to check if the directory is already made and then not mkdir if it exists? i tried if (is_dir($thisdir ."/$login") ) exit($thisdir ."/$login" .' is already made'); but it doesnt show the error message.. I'm thinking it has to be something like <?php $thisdir = getcwd(); $login = $_GET['login']; if (is_dir($thisdir ."/$login") ) { exit($thisdir ."/$login" .' is already made'); } else { if(mkdir($thisdir ."/$login" , 0755)) { } else { echo "Failed to create directory... <br> <p class='footer'>Contact <a href='mailto:[email protected]'>Drew</a></p>"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503184 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Look at my code, there's a perfect example of just that. Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503187 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 sorry, I used that but it didnt work, and then i refreshed it and it was working I dunno if my new isp is caching pages Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503214 Share on other sites More sharing options...
discomatt Posted March 28, 2008 Share Posted March 28, 2008 Caching can happen anywhere between or on the server or client machine, so that is very possible. If your ISP is caching you should drop them. Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503216 Share on other sites More sharing options...
wmguk Posted March 28, 2008 Author Share Posted March 28, 2008 Yeah currently with Orange UK, but im actually moving on 7th April and im going back to BT, as I never have any issues with them. Its only since my change to orange that things are showing up wrong... but thanks for your help so far, its all sorted now Quote Link to comment https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503288 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.