Jump to content

mkdir?


wmguk

Recommended Posts

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.

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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');

?>

Link to comment
Share on other sites

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:drew@wmguk.co.uk'>Drew</a></p>";
} }
?>

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.