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.

/files/gravity_forms/12/2011/02/Logo.png

  1. chucktho
    Member

    I'm using the Directory plugin to create a directory from a Gravity Form. I'm trying to include an image but it's not showing. When I go to Entries > View Entry, the image is listed. If I click the image it opens and shows to be in (http://tbfaa.devsite103.com/files/gravity_forms/12/2011/02/Logo.png) but I can't find that directory anywhere. I think the problem might be that I'm using a Content Delivery Network and - evidently - the image is not being uploaded there (http://tbfaanew.s3.amazonaws.com/files/gravity_forms/12/2011/02/Logo.png). I suspect that its not being found to upload it to the CDN. So the questions are 1) where do I find the directory where the images are currently being stored, and 2) is it possible to configure Gravity Forms to store images in a more "conventional" location where they will be automatically uploaded to the CDN? Thanks, Chuck

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  2. This is definitely an issue with how your site is configured to work with the CDN.

    Gravity Forms uploads files to wp-content/uploads/gravity_forms and whatever you are using to implement the CDN is interfering and hanging the URL to the file.

    You can control the upload path location Gravity Forms uses using a hook and custom PHP you would add to your functions.php file to tell Gravity Forms where to upload the file to. Here is an example of the hook:

    <?php
    add_filter("gform_upload_path", "change_upload_path", 20, 2);
    function change_upload_path($path_info, $form_id){
    $path_info["path"] = "/new/path/";
    $path_info["url"] = "http://new_url.com/images/";
    return $path_info;
    }
    ?>

    It consists of the PATH which is the FULL ABSOLUTE path on the server to the location (it must also be writeable so Gravity Forms can save the file there) and the URL which is used when displaying a link to the file in notifications, entry detail, etc.

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  3. chucktho
    Member

    Thanks Carl. I'll give it a try.

    Posted 13 years ago on Tuesday February 8, 2011 | Permalink
  4. travin
    Member

    Carl,

    I have to say, Gravity Forms never seems to amaze me on its functionality. I am trying to use your code snippet but am a little confused. The full path I want the form to upload the files to is: /home2/businfx5/public_html/secure_files

    I am not sure how to code this. my website is http://www.freeclassifiedproducts.com

    Can I have different forms upload to different folders? Also, can I prevent certain types of files types from being uploaded? Also, I don't want a url to link to the file that is uploaded as the folder I am uploading to is not publically accessable and is not even in the root directory of my website.

    Thanks for your support and help in advance.

    Daniel

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  5. Yes, you can configure different forms to upload to different folders.

    This code example:

    <?php
    add_filter("gform_upload_path", "change_upload_path", 20, 2);
    function change_upload_path($path_info, $form_id){
    $path_info["path"] = "/new/path/";
    $path_info["url"] = "http://new_url.com/images/";
    return $path_info;
    }
    ?>

    Would apply that change to ALL forms. Note you have to use the correct absolute path to the folder, you may have to work with your web host if you are unsure what that should be.

    If you want to apply this to a specific form you would use (in this example form id 5 only):

    <?php
    add_filter("gform_upload_path_5", "change_upload_path", 20, 2);
    function change_upload_path($path_info, $form_id){
    $path_info["path"] = "/new/path/";
    $path_info["url"] = "http://new_url.com/images/";
    return $path_info;
    }
    ?>

    Notice the difference in the add_filter call, the form is appended to the end and it is form id 5.

    gform_upload_path applies it to all forms.

    gform_upload_path_5 applies it just to form id 5. So you'd change _5 to whatever the form id is.

    This custom code would go in your themes functions.php file, however you have to make sure the absolute path is correct and that it is writeable for it to work.

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  6. travin
    Member

    3 more questions:

    Can I prevent certain types of files types from being uploaded?

    Does it matter that the folder I am uploading to is not publically accessable and is not even in the root directory of my website.

    I don't want a url to the file that is uploaded as I don't want folks to access them once uploaded. Can I remove that portion of the code?

    Posted 13 years ago on Thursday March 10, 2011 | Permalink
  7. One of the field options on the File Upload field is allowable file extensions. So you would limit the filetypes by their extension (ex. .jpg, .gif, .zip, etc.).

    It doesn't matter if it's accessible to the public as long as it's accessible to the PHP executing on your site. Keep in mind if it's not accessible to the public then how will you view/access it other than via directly accessing the file system? The URL in the code above is so it can create a URL to use to link to the file from the entry detail page, notification emails, etc.

    If you don't want them to access it, don't use a URL that is accessible then or use one that requires you to enter a server username/password to access by password protecting it on the server.

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