Member Avatar for LastMitch

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.

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

Member Avatar for LastMitch

Hi Pritaeas,

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.