Thread: mkdir() and ftp

    #1
  1. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    703
    Rep Power
    14

    mkdir() and ftp


    hello

    i've had this problem before but never seem to get it solved. bascially i have a system that creates a folder on my server and can upload files to it. the folder is created like so...

    mkdir ("../../works/$work_id", 0777);

    where $work_id is a unique number hence always creating a unique folder. this all works fine but from time to time i need to go to the folder via ftp to modify things. i seem to be able to delete files via ftp but not download files? i suspect my problem is the 0777 but am not sure?

    any ideas?
    gar
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Posts
    679
    Rep Power
    18
    Deleting files requires write permissions in the directory, which you have. But I assume the files in there are created by your script, so they will be owned by whatever user your scripts run as, eg. httpd, or www. Maybe you would have to modify your script to change the permissions or ownership of the files when they're created?
  4. #3
  5. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    703
    Rep Power
    14
    yes correct its an upload script on the site which puts the files in the directory and on checking again it seems the permission problem is on the file not the directory, the files are uploaded like so...

    $address = "../../works/".$work_id."/".$file_name;
    move_uploaded_file($file, $address) or die("problem");

    $work_id is the unique number of the folder, $file_name the name of the file and $file obviously the file, so how do i upload the file with the correct permissions?

    a+
    gar
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Sep 2002
    Posts
    679
    Rep Power
    18
    Hi,

    move_uploaded_file($file, $address);
    chmod($address, 0644);

    should allow you to download the file. if you want to write over it, chmod to 0666 instead.
  8. #5
  9. No Profile Picture
    rubbish in javascript
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2001
    Location
    London
    Posts
    703
    Rep Power
    14
    yep i'm using 0777 now which seems to work fine for uploading downloading and deleting the file via ftp, still can't change the permissions on the file via ftp though!

    a+
    gar

IMN logo majestic logo threadwatch logo seochat tools logo