Link to home
Start Free TrialLog in
Avatar of phper
phper

asked on

directory owner issue

I have a script that creates a directory using:
mkdir($dir,0777);
The script then uploads files to this directory.

However, it is not set to 777, but rather 755. This becomes an issue because when I'm using my ftp account I can't upload or change the permission of the directory. Meaning, that the mkdir/upload script works fine, but later in my GUI FTP I can't delete the directory or upload new files to it. Whenever I try to change the permission I get, "550 Could not change perms on MyDir: Operation not permitted  "
Avatar of NoiS
NoiS
Flag of Brazil image

Seems a limitation of your host.
Try creating the dir by your FTP GUI with 0775 or 0765, So both, PHP and FTP can change the dir content.


Avatar of phper
phper

ASKER

I can create a 777 dir in my gui ftp which uses the domain's ftp account. The problem is that these directories that are created with mkdir are dynamic for the user. I don't want to be manually creating user directories. When a user signs up it creates a dir for them, they upload to the dir, I download the files then upload a new file to the dir.
You can do the same thing with PHP using FTP funtcions.


<?php
// Connection
$conn_id = ftp_connect('ftp://localhost');
 
// login com o nome de usuário e senha
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
 
// confere a conexão
if ($conn_id && $login_result) {
  // Creating the dir
  if (ftp_mkdir($conn_id, $dir)) {
    echo "successfully created $dir\n";
  } else {
    echo "There was a problem while creating $dir\n";
  }
 
   // Putting files
   if(!ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY)){
      echo "There was a problem while putting $source_file\n";
   }
 
  // Colse connection
  ftp_close($conn_id);
}

Open in new window

Avatar of phper

ASKER

It seems that we are getting farther from my original question. The reason using php-ftp will not work is because I'm trying to use a local bat file to ftp to the directory created with mkdir.

Also, your comment, "Seems a limitation of your host." I have a vps with full root access.
ASKER CERTIFIED SOLUTION
Avatar of NoiS
NoiS
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial