icon Get the most out of Surmunity, read our tips here! Need an interesting blog to read? You've got to read the Surpass Blog! | Welcome! Please register to access all of our features.

» Surpass Web Hosting Forums » Discussions » PHP, MySQL » Cannot create folder

PHP, MySQL General PHP questions. Or go to our PHPsuexec Forum >>

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread
Old December 23rd, 2004, 1:47 PM   #1 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
6 posts
Gave thanks: 0
Thanked 0 times
Cannot create folder

I tried creating a folder but it doesn't seem to work. It creates a file but not a directory. Can u help me please?


---------
function checkDir($dir)

if (!is_dir($dir))
mkdir($dir, 777);

if (is_dir($dir))
$d = opendir($dir);

}

sample ->>>> checkDir("pics/104")
See the attached for what I'm saying. It's the last file - 104 (suppose to be a folder).

Do you have an idea why it's creating that file instead of a folder?



I really need this please.
------------------
Makavelli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 23rd, 2004, 2:02 PM   #2 (permalink)
Surpass Fan
Super #1
 
Joined in Aug 2004
Hosted on SH58
1,688 posts
Gave thanks: 6
Thanked 7 times
The parent folder needs to be chmodded to 0777 before child folders may be created.

EDIT: Upon closer investigation, it appears you need to seperate your folder path from your directory name. Like so:

function checkDir($dir)
$array = explode( "/", $dir );
if (!is_dir($array[0]))
mkdir($array[0], 777);

if (is_dir($array[0]))
$d = opendir($array[0]);

}

And that should work for you.
__________________
- Evan Charlton | [site] | Server - SH58

Last edited by Kickersny.com; December 23rd, 2004 at 2:05 PM..
Kickersny.com is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old December 24th, 2004, 12:00 AM   #3 (permalink)
Registered User
Fresh Surpasser
 
Joined in Aug 2004
6 posts
Gave thanks: 0
Thanked 0 times
The function worked on my computer but it won't work on my server. It created a binary file instead of a real folder on the server. Do you think you know what the problem is?

- - - - code - - -
if (!is_dir($dir))
[at]mkdir("$dir", 0777);

$d = opendir($dir);
Makavelli is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On