Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Warning: move_uploaded_file(upload/r) [function.move-uploaded-file]: failed to open stream: Permission denied in /home/transio/public_html/madison/lib/util/File.php on line 36

    Here's the code from lines 36-40 of the File class:
    PHP Code:
    if(move_uploaded_file($_FILES[$name]['tmp_name'], $targetPath)) {
        return 
    $this->open($targetPathself::READ_APPEND);
    } else{
        return 
    false;

    Any ideas?

    BTW, I've been having lots of issues with file permissions on my server in general... how do I give PHP R/W/E permissions on everything without opening up folders for all web users in Apache?

  2.  

  3. #2
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    If you use:
    Code:
    ls -l <file/directory>
    You'll get a listing that includes permissions in this format:
    Code:
    drwxrwxrwx
    There will usually be dashes in some of those. The first `d' indicates a directory. The first set of `rwx' is read, write, and execute permissions for the user of the file. The second set of rwx is read, write, and execute permissions for the group of the file. The third set is read, write, and execute permissions for everyone (or for `others'). Note that `execute' permissions are necessary in order to enter a directory.

    If you give rwx permissions for everyone, then you don't need to worry about additional permissions. But, this is a gaping security hole. Instead, you want to change the owner for the file to apache and give only the user read/write/execute permissions (and, often, you don't even need write or execute permissions). You can change the user and/or group of a file or directory by running:
    Code:
    chown user:group <file/directory>
    If you change the user and/or group of a directory, that change won't propagate down. You can make that happen by turning on the `recursive' flag:
    Code:
    chown -R user:group <file/directory>
    Once you've changed the owner/group, you can change permissions using [minicode]chmod[/minicode]. Typically, use pass chmod some octal numbers that decide how the permissions work (777, for example, means full permissions for user, group, and others). But, more recent versions of chmod have an easier way of specifying it:
    Code:
    chmod o+x <file/directory> # give execute permissions to others; leave other permissions alone
    chmod u+r <file/directory> # give read permissions to the user; ditto above
    chmod g+w <file/directory> # give write permissions to the group; ditto above
    chmod o-r <file/directory> # remove read permissions from others; ditto above
    chmod go=rw <file/directory> # grant group and others only read/write permissions, remove all others
    chmod ug+rwx <file/directory> # give read/write/execute permissions to the user and group, leave other permissions alone
    Again, changes won't propagate down a directory unless you specify the [minicode]-R[/minicode] flag. chmod also lets you set the setuid/setgid flags, but you typically don't want to use those and shouldn't unless you really understand what they do. They should be irrelevant to this particular problem

    All that said, for your specific issue, you probably need to change the permissions on [minicode]/tmp[/minicode], as that's where uploaded files go by default. Hopefully I didn't give you too much or too little information

  4. #3
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    ok, the issue is definitely file/directory ownership... i'm just not sure what the default apache is called. I assume I have to telnet in to do this?

  5. #4
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    SSH in. If you can telnet in, get them to turn it off! That's really dangerous.

    The apache user is, by default, just called apache. You should be able to tell by opening up your Apache config file and looking for the [minicode]User[/minicode] and [minicode]Group[/minicode] directives.

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    How do I SSH in? Is there an easy way to do it from a Windows box?

  7. #6
    Senior Member
    Join Date
    Jun 2005
    Location
    Atlanta, GA
    Posts
    4,146
    Member #
    10263
    Liked
    1 times
    I thought we'd already done this in another thread... But maybe we were talking about telnet? I forget. Anyway, PuTTY should get you in. SSH is basically Telnet, but over a secure tunnel. The advantage of this is, obviously, that neither your password nor your actions go over the wire in cleartext.

  8. #7
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    I had this exact same problem a while ago, I also posted it. But THAT had to do with my host. Transio, why don't you consult your hosting support?
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:53 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com