www.webdeveloper.com
Results 1 to 3 of 3

Thread: File Permission Trouble

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    56

    File Permission Trouble

    Ok all my files and folders are set as owner of vsftpd:nogroup. FTP program can upload and create and do everything. But when I use the PHP command mkdir, I get a Permission Denied even though the folder its creating it in is set to chmod 777. IF i set the base folder to user www-data and group www-data, PHP mkdir will work. However, I can't use FTP to delete or upload to that folder.

    /uploads is base folder.

    I use PHP mkdir to create a directory in there:

    PHP Code:
    if (!is_dir($_SERVER['DOCUMENT_ROOT'] . "/uploads/" $_REQUEST['clientID'] . '/video/')) {
        @
    mkdir($_SERVER['DOCUMENT_ROOT'] . "/uploads/" $_REQUEST['clientID'] . '/video/'0777);

    If /uploads is vsftpd:nogroup then PHP mkdir will give a Permission Denied error.

    If /uploads is www-data:www-data then PHP mkdir WILL work, but I cant continue to FTP anything in that folder that was just created.

    If /uploads is vsftpd:www-data then PHP mkdir will give a Permission Denied error.

    The username I use to FTP into the server is piagency.
    The username for this vhost is clients.thepiagency.com

    How can I create a directory with PHP and still be able to access it via FTP?

    If I have to assign people to multiple groups, how do i do that exactly? I started messing with usermod but I was afraid I would reassign someone incorrectly.

  2. #2
    Join Date
    Mar 2011
    Posts
    26
    Well I'm not that good with PHP, if I can't figure something out I just google until I find what I'm looking for. My PHP code is kind of spaghetti code, but it does the job.. If I were you I would post to a dedicated PHP message forum and someone there would be able to help you out...

  3. #3
    Join Date
    May 2010
    Posts
    77
    little rusty on this. I did write a script at one time that creates a directory and then creates directories and files in that directory. www-data does have to have read/write permissions in order for php to make the directory.

    It looks to me like your php is correct although I'm not sure about the 0777 part. I think I just used 777. I was always a little confused about the leading 0 since the 777 are for read/write/delete.

    It's confusing though because ftp access is a separate issue from your php script. I'm wondering about two things. Could it be a setting in your ftp server? And where you say www-data:www-data you mean the owner is www-data and the group is www-data as in when you view permissions in a terminal right?

    Maybe check some of the other directories on the server and see what the owner and group are set to. Because I don't think the owner and group both have to be set to www-data in order to give read/write access to www-data.

    I'll have to get to my Linux server in the morning. On a windows PC right now which obviously doesn't do any good.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles