Jump to content

Recommended Posts

$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?

Link to comment
https://forums.phpfreaks.com/topic/98281-mkdir/
Share on other sites

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
https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502924
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
https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-502959
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
https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503122
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
https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503159
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:[email protected]'>Drew</a></p>";
} }
?>

Link to comment
https://forums.phpfreaks.com/topic/98281-mkdir/#findComment-503184
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.