Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7766803
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:30:54+00:00 2026-06-01T15:30:54+00:00

Why is my mkdir not working within the if(is_dir) function but it is working

  • 0

Why is my mkdir not working within the if(is_dir) function but it is working above it with just the single line?

mkdir($location.$folderName, 0777);

            if(!is_dir($folderName))
            {   
                mkdir($location.$folderName, 0777);

            }else{

            //Set File Settings 
              $config['upload_path'] = $location.$folderName; 
              $config['allowed_types'] = 'jpg|png|pdf'; 
              $config['file_name'] = $folderName.'_'.$concept;
              $config['remove_spaces'] = TRUE;
              $config['overwrite'] = TRUE;
              $config['max_size'] = '1024'; 
              $config['max_width'] = '1024'; 
              $config['max_height'] = '768'; 

              $this->load->library('upload', $config); 

                print_r($config);

              if(!$this->upload->do_upload($conceptOne)) { #= try upload

                $data['uploadError'] = array('uploadError' => $this->upload->display_errors()); #Error

                $this->load->view('layout', $data);

          } // Do upload
              else{
                $data = array('upload_data' => $this->upload->data($conceptOne));

              }// end else
            }// end if folder
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T15:30:56+00:00Added an answer on June 1, 2026 at 3:30 pm

    Your code contradict its self … you are calling mkdir ( $location . $folderName, 0777 ); but checking ! is_dir ( $folderName )) definitely this would not work

    Try

    $location  = "" ; // Your Location 
    $foldername = "" ; // Your Folder Name
    $path = $location . DIRECTORY_SEPARATOR . $foldername ;
    
    if (!is_dir ( $path )) {
    
        if(is_writable($location))
        {
            mkdir ($path, 0777 );
        }
        else
        {
            die("You don't have permission to create folder");
        }
    }
    
     else {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code mkdir(/some/absolute/path,0777); and mkdir(relative/path, 0777); is not working, safe mode is turned off,
Recursive function for copy of multilevel folder is not working. I have a code
I think this may sound very straight forward, but still something is not working
hey there, i need to append to my file but it is not working,
The OS I'm working on (IBM CNK, which is not Linux, but somewhat POSIX-compliant)
I have this code I been working on but I'm having a hard time
I'm not sure this is the problem, but it looks like it might be
The following DOS script snippet has a bug: if not exist %MyFolder% ( mkdir
I have been trying to create a directory in /sdcard programmatically, but it's not
The Xoom does not have a working SD slot, so Moto decided to re-route

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.