|
Posted by Justin Koivisto on 10/21/05 00:08
Dave wrote:
> Hello,
> I'm using php4 and i want to check for a file, if it doesn't exist it
> should be created. My problem is i have to create it with specific
> permissions specifically 666 so that the script can then write to it. I
> don't have ftp access. I'm also looking for any tutorials, recent ones,
> using php4 for creating file upload areas, i'm trying to make one of those
> as well.
> Thanks.
> Dave.
> Thanks.
> Dave.
>
>
<?php
// if file goes into a sub-directory from this file..
$filename=dirname(__FILE__).'/sub_dir/name_of_file';
if(file_exists($filename) && is_writable($file)){
// the file exists and is able to be written to
}else if(file_exists($file)){
// file exists, but cannot be written to
}else if(is_writable(dirname($file))){
// file does not exist, but can be created
}else{
// file doesn't exist, nor can be created with current
// permission mask on parent directory: dirname($file)
}
?>
HTH
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|