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.

Extract File Upload Name in Email Notification

  1. I am trying to obtain the file name of my file upload in my gravity form notification email section. If I use the {all_fields} tag the email I get for the file upload shows the file name as the text of the link. However when I just want a specific file upload tag like {Attach file 1: 6}, the email I get shows the full url as the text of the link. Is there a way to format the tag so I only get the file name as the text of the link?
    Any help would be greatly appreciated.

    Posted 7 years ago on Wednesday July 25, 2012 | Permalink
  2. Still waiting to hear a response. It has been over a week.

    Posted 7 years ago on Friday August 3, 2012 | Permalink
  3. Thank you for bumping the topic. Sometimes the topics fall off our radar. It was unintentional. My apologies. I will take a look through the code and see what provides this functionality so we can use it in your notification. I will post back in a bit.

    Posted 7 years ago on Friday August 3, 2012 | Permalink
  4. I was not able to figure out in the plugin code if it's possible to use just the sanitized filename or not. I worked around the problem by creating a shortcode you can use in your notification area. Add this code to your theme's functions.php.

    [php]
    add_shortcode ('gf_filename', 'uploaded_file_basename');
    function uploaded_file_basename( $atts, $content = null ) {
            $filename = basename($content);
            return $filename;
    }

    Use the shortcode in your notification like this:

    [gf_filename]{MERGE TAG}[/gf_filename]

    Wrap the merge tag from the drop down in the shortcode [gf_filename]. That will output the plain text filename as it was being used in the {all_fields} notification.

    If you want to link the file to the name, exactly as it is when used in the {all_fields} notification, you can do this:

    <a href="{MERGE TAG}" title="click to view">[gf_filename]{MERGE TAG}[/gf_filename]</a>

    Be sure to use the drop down for your actual merge tag, to replace {MERGE TAG} in this example. Please let me know if you have any questions about that.

    For reference, I put the code online here as well:
    http://pastebin.com/Ta4WeEwv

    Posted 7 years ago on Friday August 3, 2012 | Permalink
  5. excellent. That worked great. Wouldnt it be better in a future release of the plugin to have this functionality built in?

    Posted 7 years ago on Tuesday August 7, 2012 | Permalink
  6. It's a good idea. It may be built in already, but I could not find it easily, so I worked around it. I'll tag this as a feature request and bring it to the attention of the developers. Maybe I made hard work of something which was actually very easy. Thank you.

    Posted 7 years ago on Tuesday August 7, 2012 | Permalink

This topic has been resolved and has been closed to new replies.