<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Renaming File Uploads?</title>
		<link>https://legacy.forums.gravityhelp.com/topic/renaming-file-uploads</link>
		<description>Gravity Support Forums Topic: Renaming File Uploads?</description>
		<language>en-US</language>
		<pubDate>Fri, 08 May 2026 03:31:31 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/renaming-file-uploads" rel="self" type="application/rss+xml" />

		<item>
			<title>Alex Cancado on "Renaming File Uploads?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/renaming-file-uploads#post-2324</link>
			<pubDate>Wed, 23 Dec 2009 05:31:57 +0000</pubDate>
			<dc:creator>Alex Cancado</dc:creator>
			<guid isPermaLink="false">2324@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;eventmedia,&#60;/p&#62;
&#60;p&#62;We don't have a hook specific for renaming the uploaded file, but with a little extra work, the post submission hook can do the trick.&#60;br /&#62;
Following is the code snippet you will need. Place it in your theme's functions.php file.&#60;br /&#62;
Also, you will need to replace the form id (line 6) and the field id's with the appropriate ones for your form (i.e. $entry[2] and $entry[1]). You can find the field id by inspecting your form's html and looking at the input name. It will be in the format name=&#34;input_ID&#34; (i.e. name=&#34;input_2&#34;)&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;add_action(&#38;quot;gform_post_submission&#38;quot;, &#38;quot;rename_file&#38;quot;, 10, 2);
function rename_file($entry, $form){

    //ignore requests from forms other than ID 18
    if($form[&#38;quot;id&#38;quot;] != 18)
        return;

    $upload_info = wp_upload_dir();

    //original name/path
    $original_file_url = $entry[2];
    $original_file_path = str_replace($upload_info[&#38;quot;baseurl&#38;quot;], $upload_info[&#38;quot;basedir&#38;quot;], $original_file_url);
    $original_file_info = pathinfo($original_file_url);

    //New File Name (without extension).
    //NOTE: Change this line to create the filename you would like to have
    $new_name = $entry[&#38;quot;id&#38;quot;] . &#38;quot;_&#38;quot; . $entry[1];

    //adding same extension as original
    $new_name .= &#38;quot;.&#38;quot; . $original_file_info[&#38;quot;extension&#38;quot;];

    $new_file_url = str_replace($original_file_info[&#38;quot;basename&#38;quot;], $new_name, $original_file_url);
    $new_file_path = str_replace($original_file_info[&#38;quot;basename&#38;quot;], $new_name, $original_file_path);

    //rename file
    $is_success = rename($original_file_path, $new_file_path);

    //if file was renamed successfully, updating entry so that it points to the new file
    if($is_success){
        global $wpdb;
        $wpdb-&#38;gt;update(RGFormsModel::get_lead_details_table_name(), array(&#38;quot;value&#38;quot; =&#38;gt; $new_file_url), array(&#38;quot;lead_id&#38;quot; =&#38;gt; $entry[&#38;quot;id&#38;quot;], &#38;quot;value&#38;quot; =&#38;gt; $original_file_url));
    }
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>eventmedia on "Renaming File Uploads?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/renaming-file-uploads#post-2287</link>
			<pubDate>Mon, 21 Dec 2009 17:27:20 +0000</pubDate>
			<dc:creator>eventmedia</dc:creator>
			<guid isPermaLink="false">2287@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks Carl.&#60;/p&#62;
&#60;p&#62;Also noticed that uploading files that have apostrophes (') in them e.g mary's%20file.ext would break the link sent to admins in email to download form attachments, another incentive (for me anyway) to look at renaming files on upload.&#60;/p&#62;
&#60;p&#62;Looking forward to seeing if any outcome. Really liking the plugin, have implemented it in a WP-based recruitment site and using GF to handle online job applications, hence the renaming of file e.g. cv_refnumber_surname_firstname.extension. Makes for easy filing on the server side of things.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "Renaming File Uploads?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/renaming-file-uploads#post-2286</link>
			<pubDate>Mon, 21 Dec 2009 17:22:05 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">2286@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I'm going to talk to the team about this.  I'm not sure if this is changeable using one of the API hooks, I don't believe it is.  If it is not we may be able to add a hook that will allow you to have some control over this.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>eventmedia on "Renaming File Uploads?"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/renaming-file-uploads#post-2283</link>
			<pubDate>Mon, 21 Dec 2009 15:05:10 +0000</pubDate>
			<dc:creator>eventmedia</dc:creator>
			<guid isPermaLink="false">2283@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hey folks,&#60;/p&#62;
&#60;p&#62;With file uploads, is it possible to rename the file during the upload process to include some of the form fields content?&#60;/p&#62;
&#60;p&#62;Say there's the name form field with FIRSTNAME and SURNAME and I'm uploading biography.doc.&#60;/p&#62;
&#60;p&#62;Is it possible to rename the file on upload to biography_SURNAME_FIRSTNAME.doc to try avoid having similar names. At present, if I upload two files called biography.doc it will go down the wordpress renaming route of adding a digit to the end of the filename so I wind up with biography.doc and biography1.doc.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
