Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

folder accessing via ftp

Explorer ,
Jun 01, 2011 Jun 01, 2011

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:

ftp_error.PNG

TOPICS
Server side applications
430
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 01, 2011 Jun 01, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2011 Jun 01, 2011

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2011 Jun 01, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines