Free Web Hosting Forum
(#1 (permalink))
Old
Junior Member
guywmustang is on a distinguished road
 
Posts: 1
Join Date: May 2008
Default chmod & mkdir not allowed?? - 05-10-2008, 03:50 PM

I have an image browser that creates thumbnails, but I cannot call 'mkdir' to create a directory in my code to put my thumbnails in. I have tried to call 'chmod' on the parent directory as well as the top level directory, but I'm DENIED.

Does this webhost not allow those functions to be called or something?

My code is as follows:
Code:
// make the thumbnail directory
if ( !(chmod('.', 0777)) )
{
    echo 'Could not change the directory\'s permissions.<br>';
}
// temporarily change parent permissions
if ( !chmod('/public_html', 0777) )
{
    echo 'Could not change top-level directory permissions.<br>';
}
else
{
    // change them back
    if ( !chmod('/public_html', 0775) )
	echo 'Could not change top-level directory permissions back.<br>';
}
if ( !(mkdir( './thumbnails/', 0777, true )) )
{
    echo 'Could not create directory: ' . $this->path;
    echo '<br>Thumbnails cannot be created.';
    return false;
}
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Junior Member
Karuhun is on a distinguished road
 
Posts: 14
Join Date: May 2008
Default 05-10-2008, 04:46 PM

I think it's not allowed. But you can create it via ftp client, chmod it from there.
Reply With Quote
(#3 (permalink))
Old
Member
drmmr763 is on a distinguished road
 
Posts: 81
Join Date: Apr 2008
Default 05-13-2008, 04:20 AM

Permission can be denied because of ownership problems. If you reset ownership in Cpanel, you may be able to fix this problem.
Reply With Quote
(#4 (permalink))
Old
Junior Member
jijikikishoes is on a distinguished road
 
Posts: 19
Join Date: Jun 2008
Default 06-24-2008, 01:01 PM

This is because the php scripts are in the 99 group but all the directories under publichtml are in a group of your user name.

To create a directory you have to temporarily change the publichtml directory permissions to 777, do not leave them like this. After the new directory is created change your publichtml back to 775. Once you have created the directory your php scripts can chown and chmod it as much as you like.

Any file's you create through cpanel will be of limits for php to chmod and chown but any files or directories php creates can be modified with chmod and chown from php scripts.

It’s all to do with the permissions and the groups.

Note: some people will say just leave the publichtml as 777 but this means anyone on the server can create a script to delete all your files or run malicious code from your site.
Reply With Quote
(#5 (permalink))
Old
Banned
YaThisHostRox is on a distinguished road
 
Posts: 371
Join Date: Jul 2008
Location: IM me plz. I need more intelligence.
Send a message via AIM to YaThisHostRox Send a message via MSN to YaThisHostRox Send a message via Yahoo to YaThisHostRox Send a message via Skype™ to YaThisHostRox
Default 07-03-2008, 12:09 AM

PHP runs as a1234567 (or whatever). Uploads and misc. are assigned to the 99 group. Resetting ownerships in cPanel can solve your prob.0
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 Off
Pingbacks are Off
Refbacks are Off




Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com