QAds
12 Ay Taksit
Samsung S5233 with 3 MP Camera, MP3 player
$93.99
Canon Digital Rebel XSi 12.2 MP Digital SLR Camera with EF-S 18-55mm f/3.5-5.6 IS Lens (Black)
$250.34
Nikon D3000 10.2MP Digital SLR Camera with 18-55mm f/3.5-5.6G AF-S DX VR Nikkor Zoom Lens
$232.76
Toshiba Satellite T115D-S1125 LED TruBrite Laptop
$248.28
:: HOME » PHP » Creating Folder With FTP
 
Creating Folder With FTP

If you want to create a folder with using PHP you can just use mkdir function of PHP to do it. as a first variable we define folder and then we define mod of folder.

<?PHP
    mkdir("foldername", 0777);
?>

If you dont know what these numbers mean, you need to check CHMOD.

But some times because of authentication, you can not define CHMOD with mkdir function. The best way to create folder with PHP is using ftp.

function FTPmkdir($name, $mod = 777)
{

    $path="/httpdocs/"; // location
    $newDir=$name;
    $server='255.255.255.255';  // server IP address
    $connection = ftp_connect($server);

    $user = ""; // FTP user name
    $pass = ""; // FTP password
    $result = ftp_login($connection, $user, $pass);

    if ((!$connection) || (!$result)) {
        return false;
        exit();
    } else {
        if (!ftp_chdir($connection, $path)) {
            $r = false;
        } else if (!ftp_mkdir($connection,$newDir)) {
            $r = false;
        } else if (!ftp_site($connection, "CHMOD ".$mod."/".$path."/".$newDir))
        {
            $r = false;
        } else {
            $r = $newDir;
        }
    }
    ftp_close($connection);
    return $r;
}

 

Here you just need to send folder name to function. Also if you want you can send to CHMOD too. You need to type your server IP address, location for new folder, ftp user name and password.

 

Thats it.


PHP Creating Folder With FTP PHP Creating Folder With FTP PHP Creating Folder With FTP
PHP Creating Folder With FTP
NEW QUESTION
 
Your E-Mail Address
»
Your e-mail will never be shown!  
   
 
Question
»
Please type your question and please use [CODE] tag for your codes!  
  Add CODE Quote BOLD ITALIC Underline Align Left Align Center Align Right Add Line  
   
 
Human Check
»
Enter human check code below!  
   
 
       
 
* Your Question will be answered as soon as possible, probably within 24 hours!
PHP Creating Folder With FTP PHP Creating Folder With FTP PHP Creating Folder With FTP
PHP Creating Folder With FTP
 
Website Designer, Search Engine Optimization Expert, Ajax Developer,Developed And Designed By Mumin Celik With Using PHP, MySQL, CSS, JavaScript, Ajax And Search Engine Optimizer Sinema ve Film Rehberi Sudoku Oyunu