You are here: Re: creating a file, uploading, and permissions « PHP Programming Language « IT news, forums, messages
Re: creating a file, uploading, and permissions

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация