It appears you have not yet registered with our community. To register please click here..

CirtexHosting Community - Video Hosting Forums  

Go Back   CirtexHosting Community - Video Hosting Forums > CirtexHosting Community > Website Development & Scripting

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2007, 07:15 PM
Registered User
 
Join Date: Jun 2007
Location: Earth, my favorite planet in the Universe (It has the best people I've ever met there).
Posts: 8
mkdir PHP not working

Hello,

I just moved my website over, and some of my files aren't working (specifically the ones with PHP "mkdir," do you know why my PHP files can't create directories? E.g. ...

<?
mkdir($_SERVER['DOCUMENT_ROOT'].'/test', 0777)
?>

Does anyone have any idea why the command above doesn't work? PHP will not create the folder.

Thank you,
David
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-20-2007, 02:03 AM
Registered User
 
Join Date: Jun 2007
Location: Earth, my favorite planet in the Universe (It has the best people I've ever met there).
Posts: 8
I have learned that PHP runs as a generic user...

Can this be changed?

I just need to have PHP able to create folders and files in the most secure manner possible, how can I achieve this?

Thank you...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-26-2007, 05:35 AM
Registered User
 
Join Date: Feb 2007
Posts: 122
Try this instead
PHP Code:
<?PHP

// it will default to 0755 regardless
mkdir(dirname(__FILE__).'/test'0755);

// Finally, chmod it to 777
chmod(dirname(__FILE__).'/test'0777);

?>
If it does not work, be sure to chmod the folder where that script is located to 757 or 777.
(777 only if 757 fails)

Also, would be more secure to create a subfolder inside the folder where the script is (or another location) where more folders/files will be created instead of the same directory as the script itself. Because we need to grant write access to PHP using 757 instead of the default 755.

example:

script_folder/script.php
script_folder/folders/ (chmod folders to 757 or 777 if 757 fails)

Then make the script do as this instead:
PHP Code:
<?PHP

// it will default to 0755 regardless
mkdir(dirname(__FILE__).'/folders/test'0755);

// Finally, chmod it to 777
chmod(dirname(__FILE__).'/folders/test'0777);

?>
This way the script itself is not in a directory that can be written to. Hope that helps!

// Regards,
Doug

Last edited by dougp; 06-26-2007 at 06:02 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-26-2007, 08:15 AM
Registered User
 
Join Date: Jun 2007
Location: Earth, my favorite planet in the Universe (It has the best people I've ever met there).
Posts: 8
Thank you

Thank you very much for your reply. I should have written earlier to this post, but I have figured it out, using a different method to use mkdir.

Basically, I turned folder privalges to least possible security, made the folder, than turned security back up high so it could only be edited by the owner (me).

I'm not sure why, but as long as PHP had made the folder 757, it could do whatever it wanted with it, but if I made the folder at 757, it couldn't. Oh well. If I do run into future problems, I'll be sure to return to this post and try what you've said. Thank you very much!!!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-26-2007, 08:18 AM
Registered User
 
Join Date: Feb 2007
Posts: 122
no prob, the above I posted however will do exactly what your wanting and will chmod the folder 777 for you, tested and works. Either way, glad to try and help.

Take care,
Doug
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not 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


All times are GMT -4. The time now is 10:36 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17