Here is a function you and others may find helpful. It may need some work, I
haven't fully checked it out.
DOC_ROOT is $_SERVER['DOCUMENT_ROOT']
ftp_conn() is a simple ftp connection function.
/**
* dir_perms()
*
* Checks to see who is dir owner and uses ftp or php to change permissions
*
* @param string $mode; read/execute 755 or read/write/execute 757 Use read or
write 757 required to delete files and remove dir
* @param mixed $dir; can be full or relative to doc root
* @return TRUE or FALSE
*/
function dir_perms($mode='read', $dir){
if(!isset($mode, $dir))
die ("dir_perms() did not receive mode or dir. Tech support required.");
$perms= ($mode== 'write')? 0757 : 0755;
$pattern= DOC_ROOT;
$fpdir= preg_match("%$pattern%i", $dir)? $dir : DOC_ROOT . $dir; //full
path
$rpdir= preg_replace("%$pattern%i", '', $dir); //relative to
DOC_ROOT for ftp
if(!file_exists($fpdir)) return FALSE;
//See who is dir owner
if(fileowner($fpdir) == getmyuid()){ //File is site owner
$conn_id= ftp_conn();
if(!ftp_chmod($conn_id, $perms, $rpdir)) {
ftp_close($conn_id);
return FALSE;
}
ftp_close($conn_id);
return TRUE;
}
else{
if(chmod($fpdir, $perms)) return TRUE;
return FALSE;
}
}//END FUNCTION
Ross wrote:
Hi,
I can make the files now after setting the permission to my images folder
but I cannot delete the folder or images in it. I have tried unlink and
rmdir with no success. Even with filezilla cannot delete it
The problem seems to be the images that are set to chmod of 600 and cannot
be changed. I upload the file with this
move_uploaded_file($_FILES['userfile']['tmp_name'][$i], $img_url)
is there a way to set the permissions of the images on upload to anything
other than 600?
R.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php