470,848 Members | 1,193 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,848 developers. It's quick & easy.

creating a file, uploading, and permissions

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.
Oct 20 '05 #1
1 1349
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 - ju****@koivi.com
http://koivi.com
Oct 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Seb | last post: by
6 posts views Thread by jonathanmcdougall | last post: by
2 posts views Thread by Christoffer Sørensen | last post: by
2 posts views Thread by Jay | last post: by
15 posts views Thread by David Thielen | last post: by
4 posts views Thread by Mukesh | last post: by
reply views Thread by Tim Payne | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.