0

Hi

I'm having an issue with the chmod. I can't seem to excute the file. Everytime I upload a file and write something it keep saying "Directory is not writable chmod(700)

Here is the code:

function checkPath ($path) {
if (!is_dir ($path)) {
printSecurityText ("Directory does not exist: ".$path."");      
return false;
}
else {
if (!is_writable ($path)) {
$tmpFilename = time ().".tmp";          
$chmodList = array (0666, 0700, 0744, 0746, 0747);
foreach ($chmodList as $chmod) {
if (chmod($path, $chmod)) {
if ($fh = fopen ($path."/".$tmpFilename, "w+")) {
unlink ($path."/".$tmpFilename);
return true;
}   
}           
}           
printSecurityText ("Directory is not writable: ".$path."");     
return false;
}
}   
return true;
}

function checkFile ($filename, $fExists=false) {
if ($fExists && !file_exists ($filename)) {
printSecurityText ("File does not exist: ".$filename."");       
return false;
}
else 
if (!is_writable ($filename)) {
printSecurityText ("File is not writable: ".$filename."");      
return false;
}
return true;
}

I appreciate any suggestion. Thanks.

Edited by LastMitch

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by LastMitch
1

Are you trying to run this on a shared host? Most likely that you are not allowed to run chmod.

0

Hi Pritaeas,

Thanks for the reply. Yes, I was trying this on my shared host. I knew that but wasn't too sure. Thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.