PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

File upload permission

  1. MellyVille
    Member

    File upload is working great, it's just that files are placed on the server with 600 permission, while i need them to be 644 in order for me to download the files directly from the link that's mailed to me.

    Where can i set GF to use 644 instead of 600?

    Thanks in advance

    Posted 13 years ago on Monday January 31, 2011 | Permalink
  2. GF does not set file permissions when uploading files. You will need to talk to your hosting folks and ask them to change the default permissions for the wp-content/uploads folder.

    Posted 13 years ago on Tuesday February 1, 2011 | Permalink
  3. MellyVille
    Member

    Well, how is it that normally every file is added in 644 and now as 600? I remember it to be a WP-hook which must be applied in the plugin files, is that correct?

    Posted 13 years ago on Tuesday February 1, 2011 | Permalink
  4. MellyVille
    Member

    Still, all files are added with 600 permissions while they should be with 644 permissions. Anyone that can help?

    Posted 13 years ago on Thursday February 3, 2011 | Permalink
  5. MellyVille
    Member

    Hello, anyone that can help? My hoster blaims it on the script, so i'm kind of stuck here!

    Posted 13 years ago on Thursday February 10, 2011 | Permalink
  6. We are aware it's possible to set the file permission with PHP, however it's not typically needed. This is the first time this issue has come up. Default file permissions are set based on the owner of the files, and typically this default 'owner' has the correct file permissions assigned to them (644).

    If this was working before, and now it is not it means something changed with your web host. Your web host has changed the defaults. The script hasn't changed, your web host changed something on their end.

    For example if your web server is running apache then by default file uploads would be 'owned' by apache and receive apache's default file permissions. Typically this is 644.

    So this has to do with the settings your host has on the user that owns files that are uploaded by default. They had to have changed something for this issue to start happening.

    Posted 13 years ago on Thursday February 10, 2011 | Permalink
  7. MellyVille
    Member

    Hi Carl,

    Thanks for the response. It has not been working before. I am using this on a newly developed site and the other sites i've used the plugin on, doesn't use the file upload. This is my first use and it has not ever worked for me.

    I am aware of the owner setup, and this is correct every time. That's why it must be in the script somewhere.

    I would be glad if you could come up with a solution to write the files with the right permission.

    Thanks!
    Melvin

    Posted 13 years ago on Thursday February 10, 2011 | Permalink
  8. Gravity Forms does not explicitly set the file permissions. If the owner is setup to use 644 then file uploads from Gravity Forms should be using 644 also. Gravity Forms is not setting the file permissions, it's leaving it up to the server to set the file permissions. The server should be using the default file permissions for the owner, which should be 644. Your server obviously isn't setup for the default owner of file uploads to use 644 which is why they are storing as 600.

    Posted 13 years ago on Thursday February 10, 2011 | Permalink
  9. MellyVille
    Member

    Hi Carl,

    I managed to solve this myself by changing:

    if(move_uploaded_file($file['tmp_name'], $target["path"])){
    			return $target["url"];
            }

    to:

    if(move_uploaded_file($file['tmp_name'], $target["path"])){
    			chmod( $target["path"] , 0644 );
    			return $target["url"];
            }

    Otherwise it wouldn't be solvable in my case, although every server setting is set right. Happy with my solution in the end :)

    Posted 13 years ago on Tuesday March 1, 2011 | Permalink
  10. Thanks for the feedback!
    We have added a hook to 1.5 that you can use to set the file permissions without changing a core file. Keep an eye on our next release.

    Posted 13 years ago on Thursday March 3, 2011 | Permalink