creating a file, uploading, and permissions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    #1

    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.


  • Justin Koivisto

    #2
    Re: creating a file, uploading, and permissions

    Dave wrote:[color=blue]
    > 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.
    >
    >[/color]

    <?php
    // if file goes into a sub-directory from this file..
    $filename=dirna me(__FILE__).'/sub_dir/name_of_file';

    if(file_exists( $filename) && is_writable($fi le)){
    // 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.co m

    Comment

    Working...