简体   繁体   中英

php directory password protection

I've got a php code:

    if (isset($_POST['submit'])) {

    $name = $_POST['gname'];
    $description = $_POST['gdescription'];

    mkdir ("upload/$name", 0777);

}

which works perfectly fine however is there a way to password protect the new directory when the form creates it and the password itself is defined by the user via one of the fields in the form?

There is a chown () function in PHP which will set the owner of the folder to a specific user, but that user needs to be defined on the server running the system.

The better approach would be to simply do the ownership via the page itself to ensure that only the right owner can access the files inside it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM