Using VPS server when I create directory using mkdir() it returns true but folder when I check using cpanel is blank,










0















Using VPS server when I create directory using mkdir() it returns true but folder when I check using cpanel is blank, I dont know why I even used scandir() and I noticed that those folders which I created is showing in an array in scandir(), why is that happening, why those folders are not showing ?
This is my code:



/creating directory/



 if (!file_exists('public_html/members/1213121')) 
mkdir('public_html/members/1213121', 0777, true);
echo "file getting created";

else
echo "file not getting created.";


/**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

$dir = "public_html/members/";

// Sort in ascending order - this is default
$a = scandir($dir);

// Sort in descending order
$b = scandir($dir,1);

print_r($b);


since I did the testing with other folder names also so it returns in html as below::
file getting created
Array ( [0] => 1213121 [1] => 12131 [2] => 1213 [3] => .. [4] => . )



Also I did the testing with permissions as 0755, 0700 but none is working.










share|improve this question
























  • what does error reporting throw back? php.net/manual/en/function.error-reporting.php

    – Funk Forty Niner
    Nov 15 '18 at 19:18











  • That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

    – Manjot
    Nov 15 '18 at 19:21












  • "it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

    – Patrick Q
    Nov 15 '18 at 19:28












  • When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

    – Manjot
    Nov 15 '18 at 19:32















0















Using VPS server when I create directory using mkdir() it returns true but folder when I check using cpanel is blank, I dont know why I even used scandir() and I noticed that those folders which I created is showing in an array in scandir(), why is that happening, why those folders are not showing ?
This is my code:



/creating directory/



 if (!file_exists('public_html/members/1213121')) 
mkdir('public_html/members/1213121', 0777, true);
echo "file getting created";

else
echo "file not getting created.";


/**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

$dir = "public_html/members/";

// Sort in ascending order - this is default
$a = scandir($dir);

// Sort in descending order
$b = scandir($dir,1);

print_r($b);


since I did the testing with other folder names also so it returns in html as below::
file getting created
Array ( [0] => 1213121 [1] => 12131 [2] => 1213 [3] => .. [4] => . )



Also I did the testing with permissions as 0755, 0700 but none is working.










share|improve this question
























  • what does error reporting throw back? php.net/manual/en/function.error-reporting.php

    – Funk Forty Niner
    Nov 15 '18 at 19:18











  • That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

    – Manjot
    Nov 15 '18 at 19:21












  • "it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

    – Patrick Q
    Nov 15 '18 at 19:28












  • When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

    – Manjot
    Nov 15 '18 at 19:32













0












0








0








Using VPS server when I create directory using mkdir() it returns true but folder when I check using cpanel is blank, I dont know why I even used scandir() and I noticed that those folders which I created is showing in an array in scandir(), why is that happening, why those folders are not showing ?
This is my code:



/creating directory/



 if (!file_exists('public_html/members/1213121')) 
mkdir('public_html/members/1213121', 0777, true);
echo "file getting created";

else
echo "file not getting created.";


/**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

$dir = "public_html/members/";

// Sort in ascending order - this is default
$a = scandir($dir);

// Sort in descending order
$b = scandir($dir,1);

print_r($b);


since I did the testing with other folder names also so it returns in html as below::
file getting created
Array ( [0] => 1213121 [1] => 12131 [2] => 1213 [3] => .. [4] => . )



Also I did the testing with permissions as 0755, 0700 but none is working.










share|improve this question
















Using VPS server when I create directory using mkdir() it returns true but folder when I check using cpanel is blank, I dont know why I even used scandir() and I noticed that those folders which I created is showing in an array in scandir(), why is that happening, why those folders are not showing ?
This is my code:



/creating directory/



 if (!file_exists('public_html/members/1213121')) 
mkdir('public_html/members/1213121', 0777, true);
echo "file getting created";

else
echo "file not getting created.";


/**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

$dir = "public_html/members/";

// Sort in ascending order - this is default
$a = scandir($dir);

// Sort in descending order
$b = scandir($dir,1);

print_r($b);


since I did the testing with other folder names also so it returns in html as below::
file getting created
Array ( [0] => 1213121 [1] => 12131 [2] => 1213 [3] => .. [4] => . )



Also I did the testing with permissions as 0755, 0700 but none is working.







php mkdir scandir






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 19:20







Manjot

















asked Nov 15 '18 at 19:16









ManjotManjot

5219




5219












  • what does error reporting throw back? php.net/manual/en/function.error-reporting.php

    – Funk Forty Niner
    Nov 15 '18 at 19:18











  • That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

    – Manjot
    Nov 15 '18 at 19:21












  • "it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

    – Patrick Q
    Nov 15 '18 at 19:28












  • When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

    – Manjot
    Nov 15 '18 at 19:32

















  • what does error reporting throw back? php.net/manual/en/function.error-reporting.php

    – Funk Forty Niner
    Nov 15 '18 at 19:18











  • That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

    – Manjot
    Nov 15 '18 at 19:21












  • "it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

    – Patrick Q
    Nov 15 '18 at 19:28












  • When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

    – Manjot
    Nov 15 '18 at 19:32
















what does error reporting throw back? php.net/manual/en/function.error-reporting.php

– Funk Forty Niner
Nov 15 '18 at 19:18





what does error reporting throw back? php.net/manual/en/function.error-reporting.php

– Funk Forty Niner
Nov 15 '18 at 19:18













That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

– Manjot
Nov 15 '18 at 19:21






That is the thing , it is not showing any error, it is returning true and directories are being created according to php code it is going to if statement not else... but those folders are not there in members directory when I used cpanel. I am using error_reporting(E_ALL); ini_set('display_errors', 1); in my file and none of the error is being returned.

– Manjot
Nov 15 '18 at 19:21














"it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

– Patrick Q
Nov 15 '18 at 19:28






"it is returning true" Where exactly are you checking that? Not in the code above. Entering the if shown above simply means that the given file/directory doesn't exist, not that anything was (or wasn't) created.

– Patrick Q
Nov 15 '18 at 19:28














When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

– Manjot
Nov 15 '18 at 19:32





When I am using scandir(), it is returning those foldernames in an array and plus there is no error so what should that mean.. Am I right? what should I do if I am wrong can you please tell ?

– Manjot
Nov 15 '18 at 19:32












2 Answers
2






active

oldest

votes


















2














if your server folder permission is ok then this code is work for you.
this first script for deleting the '1213121' folder from your server.
script 1:



delete_files('/public_html/members/1213121/');

/*
* php delete function that deals with directories recursively
*/
function delete_files($target)
if(is_dir($target))
$files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

foreach( $files as $file )
delete_files( $file );


rmdir( $target );
elseif(is_file($target))
unlink( $target );


?>


replace your script with this script 2:



$dir = 'public_html/members/1213121';

if (!file_exists($dir) && !is_dir($dir)) //check dir is not exist

if (mkdir($dir, 0777, true)) //check folder is created
echo "Folder created"; //display success message
else
echo "folder not created."; //if the dir is not created then show error message



/**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

$dir = "public_html/members/";

// Sort in ascending order - this is default
$a = scandir($dir);

// Sort in descending order
$b = scandir($dir, 1);

print_r($b);


Note: before replacing 2nd script you must remove e first script.






share|improve this answer






























    0














    The problem is solved actually the file which is creating the folder is in the subdomain and when I put the exact path , it was not pointing to it instead it created new public_html folder in subdomain and I was in main public_html.. it created a path like:-public_html/subdomainfolder/public_html/members/1213121 and instead i was thinking that path will be created as public_html/members/1213121 ... So my problem is solved now and Mahfuz answer is also right. thanks for the help.






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326487%2fusing-vps-server-when-i-create-directory-using-mkdir-it-returns-true-but-folde%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      if your server folder permission is ok then this code is work for you.
      this first script for deleting the '1213121' folder from your server.
      script 1:



      delete_files('/public_html/members/1213121/');

      /*
      * php delete function that deals with directories recursively
      */
      function delete_files($target)
      if(is_dir($target))
      $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

      foreach( $files as $file )
      delete_files( $file );


      rmdir( $target );
      elseif(is_file($target))
      unlink( $target );


      ?>


      replace your script with this script 2:



      $dir = 'public_html/members/1213121';

      if (!file_exists($dir) && !is_dir($dir)) //check dir is not exist

      if (mkdir($dir, 0777, true)) //check folder is created
      echo "Folder created"; //display success message
      else
      echo "folder not created."; //if the dir is not created then show error message



      /**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

      $dir = "public_html/members/";

      // Sort in ascending order - this is default
      $a = scandir($dir);

      // Sort in descending order
      $b = scandir($dir, 1);

      print_r($b);


      Note: before replacing 2nd script you must remove e first script.






      share|improve this answer



























        2














        if your server folder permission is ok then this code is work for you.
        this first script for deleting the '1213121' folder from your server.
        script 1:



        delete_files('/public_html/members/1213121/');

        /*
        * php delete function that deals with directories recursively
        */
        function delete_files($target)
        if(is_dir($target))
        $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

        foreach( $files as $file )
        delete_files( $file );


        rmdir( $target );
        elseif(is_file($target))
        unlink( $target );


        ?>


        replace your script with this script 2:



        $dir = 'public_html/members/1213121';

        if (!file_exists($dir) && !is_dir($dir)) //check dir is not exist

        if (mkdir($dir, 0777, true)) //check folder is created
        echo "Folder created"; //display success message
        else
        echo "folder not created."; //if the dir is not created then show error message



        /**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

        $dir = "public_html/members/";

        // Sort in ascending order - this is default
        $a = scandir($dir);

        // Sort in descending order
        $b = scandir($dir, 1);

        print_r($b);


        Note: before replacing 2nd script you must remove e first script.






        share|improve this answer

























          2












          2








          2







          if your server folder permission is ok then this code is work for you.
          this first script for deleting the '1213121' folder from your server.
          script 1:



          delete_files('/public_html/members/1213121/');

          /*
          * php delete function that deals with directories recursively
          */
          function delete_files($target)
          if(is_dir($target))
          $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

          foreach( $files as $file )
          delete_files( $file );


          rmdir( $target );
          elseif(is_file($target))
          unlink( $target );


          ?>


          replace your script with this script 2:



          $dir = 'public_html/members/1213121';

          if (!file_exists($dir) && !is_dir($dir)) //check dir is not exist

          if (mkdir($dir, 0777, true)) //check folder is created
          echo "Folder created"; //display success message
          else
          echo "folder not created."; //if the dir is not created then show error message



          /**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

          $dir = "public_html/members/";

          // Sort in ascending order - this is default
          $a = scandir($dir);

          // Sort in descending order
          $b = scandir($dir, 1);

          print_r($b);


          Note: before replacing 2nd script you must remove e first script.






          share|improve this answer













          if your server folder permission is ok then this code is work for you.
          this first script for deleting the '1213121' folder from your server.
          script 1:



          delete_files('/public_html/members/1213121/');

          /*
          * php delete function that deals with directories recursively
          */
          function delete_files($target)
          if(is_dir($target))
          $files = glob( $target . '*', GLOB_MARK ); //GLOB_MARK adds a slash to directories returned

          foreach( $files as $file )
          delete_files( $file );


          rmdir( $target );
          elseif(is_file($target))
          unlink( $target );


          ?>


          replace your script with this script 2:



          $dir = 'public_html/members/1213121';

          if (!file_exists($dir) && !is_dir($dir)) //check dir is not exist

          if (mkdir($dir, 0777, true)) //check folder is created
          echo "Folder created"; //display success message
          else
          echo "folder not created."; //if the dir is not created then show error message



          /**this is the code I put to scan the members folder and it retuns array and showing the folder named 1213121 but in actual cpanel that directory is not there **/

          $dir = "public_html/members/";

          // Sort in ascending order - this is default
          $a = scandir($dir);

          // Sort in descending order
          $b = scandir($dir, 1);

          print_r($b);


          Note: before replacing 2nd script you must remove e first script.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 20:42









          Mahfuzar RahmanMahfuzar Rahman

          14919




          14919























              0














              The problem is solved actually the file which is creating the folder is in the subdomain and when I put the exact path , it was not pointing to it instead it created new public_html folder in subdomain and I was in main public_html.. it created a path like:-public_html/subdomainfolder/public_html/members/1213121 and instead i was thinking that path will be created as public_html/members/1213121 ... So my problem is solved now and Mahfuz answer is also right. thanks for the help.






              share|improve this answer



























                0














                The problem is solved actually the file which is creating the folder is in the subdomain and when I put the exact path , it was not pointing to it instead it created new public_html folder in subdomain and I was in main public_html.. it created a path like:-public_html/subdomainfolder/public_html/members/1213121 and instead i was thinking that path will be created as public_html/members/1213121 ... So my problem is solved now and Mahfuz answer is also right. thanks for the help.






                share|improve this answer

























                  0












                  0








                  0







                  The problem is solved actually the file which is creating the folder is in the subdomain and when I put the exact path , it was not pointing to it instead it created new public_html folder in subdomain and I was in main public_html.. it created a path like:-public_html/subdomainfolder/public_html/members/1213121 and instead i was thinking that path will be created as public_html/members/1213121 ... So my problem is solved now and Mahfuz answer is also right. thanks for the help.






                  share|improve this answer













                  The problem is solved actually the file which is creating the folder is in the subdomain and when I put the exact path , it was not pointing to it instead it created new public_html folder in subdomain and I was in main public_html.. it created a path like:-public_html/subdomainfolder/public_html/members/1213121 and instead i was thinking that path will be created as public_html/members/1213121 ... So my problem is solved now and Mahfuz answer is also right. thanks for the help.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 15 '18 at 20:52









                  ManjotManjot

                  5219




                  5219



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53326487%2fusing-vps-server-when-i-create-directory-using-mkdir-it-returns-true-but-folde%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Barbados

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Node.js Script on GitHub Pages or Amazon S3