Copy link to clipboard
Copied
i am trying to access a folder that is created on the server. here is my code that I use to create it:
<?php
if (isset($_POST['submit'])) {
$name = $_POST['gname'];
$description = $_POST['gdescription'];
mkdir("$name",'0777');
}
?>
here is the error i get when i try to access the folder on the server:
Copy link to clipboard
Copied
Given that your code is PHP I'll assume a Unix server. I don't see this as much anymore, but if your host is not running suPHP then scripts creating through web programming will be created with the ownership of user "nobody" in which case since you are not "nobody" you do not have ownership rights to modify the folder. I can't say 100% that this is the case, but it is a strong possibility. If you have a decent FTP client you might be able to read the ownership properties (or via web-based administration). It is possible that your host might need to get involved if you do not have ownership of the folder.
Copy link to clipboard
Copied
i guess there is a difference b/w a directory and a folder.... you cannot access a directory. so i guess i have to create a folder. i would like a folder created when a user signs up on my site.
Copy link to clipboard
Copied
future-architect wrote:
i guess there is a difference b/w a directory and a folder....
You guess wrong. The correct computer terminology is directory. Windows and Mac both thought that sounded too intimidating for non-technical people, so they used the term "folder" instead. Folders and directories are the same.
Looking at your original code, I notice a couple of things:
if (isset($_POST['submit'])) {
$name = $_POST['gname'];
$description = $_POST['gdescription'];
mkdir("$name",'0777');
}
First of all, you're not making any checks on the value of $_POST['gname']. It could contain illegal characters or be trying to probe your file system.
Secondly, you're not checking whether there's already a directory of the same name.
Thirdly, you don't need quotes around $name in the first argument to mkdir(). The variable on its own is enough. Even more important, there should not be any quotes around 0777. It's an octal number, not a string. In fact, you don't need the second argument, because 0777 is the default value.
Finally, what operating system is your server running on? The second argument to mkdir() has no effect on a Windows server.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now