I've been experimenting with uploading files through an HTML form and accepting them in PHP. As you know, it goes a little something like this:

        <form action="" method="post" enctype="multipart/form-data">
                File to upload:
                <input name="userfile" type="file" />
                <input type="submit" name="submit" value="Upload File" />
        </form>

...

<?php
        $uploaddir = "./";
        $uploadfile = $uploaddir . $_FILES['userfile']['name'];

                if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile))
                {
                        print "File is valid, and was successfully uploaded. ";
                        print "Here's some more debugging info:\n";
                        print_r($_FILES);
                }
?>

My question is about permissions. The folder to which the file is uploaded has to be world writable (777) and after being uploaded it is owned by "99", which is apparently Apache. I can't copy it to other folders unless they too are 777. I can't change the owner to me because I don't have root access (it's a shared server.) It feels like uploading files through an HTML form is a can of worms. What do I do? Set permission to 777 for all the folders that will use uploaded files? (Any reason not to choose 777 in this shared server environment if I'm the only user anyway?)

Many thanks,

Richard


____________________
BYU Unix Users Group http://uug.byu.edu/ ___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to