SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict palgrave's Avatar
    Join Date
    Jan 2006
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    chmod not working every time

    I have the following in a file:

    PHP Code:
      $result  =  move_uploaded_file($temp_name$file_path);
      if (!
    chmod($file_path,0777))
           
    $message "change permission to 777 failed.";
      else
        
    $message = ($result)?"$file_name was uploaded successfully." :
                   
    "Something is wrong with uploading the file.";
      return 
    $message;

    and everything goes smoothly 9 times out of 10. However, sometimes the chmod doesn't work and I get the "change permission to 777 failed." message.

    Are there any usual suspects for this sort of behaviour?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    To start figuring out why that's happening, I'd start by checking if the move_uploaded_file worked and the file you're trying to chmod() exists at that path.

  3. #3
    SitePoint Addict palgrave's Avatar
    Join Date
    Jan 2006
    Posts
    357
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Dan. Tried that, but the move_upload_file works ok.


Bookmarks

Posting Permissions

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