Lennard K
Lennard K

Reputation: 52

Php Folder making with ftp

I have a webserver and if I make a folder on that webserver with php the webserver will make the folder. But if I want to create a folder inside the folder I just created, it spits out an error.

"Warning: ftp_mkdir(): Directory send OK. in C:......."

It probably has to do with the permissions from that folder but I don't know for sure.

Does anyone have an idea?

at server end I tried

sudo chown *user* /var/www/

but that didn't work.

Code:

// config ftp 
include '../config/ftpservers/Ftpserver.php';

// foldername 
$foldername = 'Project-'.$randomtoken.'-'.$projectname;
$dir = "/html/upload/projects/".$foldername;

if(ftp_mkdir($ftpConn, $dir))
{
    $dir2 = "/html/upload/projects/".$foldername.'/mainfiles';

    if(ftp_mkdir($ftpConn, $dir2))
    {
        $dir3 = "/html/upload/projects/".$foldername.'/copys';

        if(ftp_mkdir($ftpConn, $dir3))
        {
            $dir4 = "/html/upload/projects/".$foldername.'/pictures';

            if(ftp_mkdir($ftpConn, $dir4))
            {
                'INSTERT TO DATABASE'
            }else{
                echo "Problem with making directory $dir4";
            }
        }
        else
        {
            echo "Problem with making directory $dir3";
        }
    }
    else
    {
        echo "Problem with making directory $dir2";
    }
}
else
{
    echo "Problem with making directory $dir";
}

EDIT

I have found the problem it was in the ownership off the created directory. if the first directory was made it has no owner so i can not make a directory inside off it.

Tried multiple things

I Tried to set local_unmask to 022 but that didn't work. I also tried to set file_open_mode to 0777 but that didn't work either. closer by the problem but still coudn't find a way to fix it

Upvotes: 0

Views: 59

Answers (0)

Related Questions