<?xml version="1.0"?><!-- generator="bbPress" -->

<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
>

<channel>
<title>MachForm Community Forums Topic: Renaming Files on Upload</title>
<link>https://www.machform.com/forums/</link>
<description>MachForm Community Forums Topic: Renaming Files on Upload</description>
<language>en</language>
<pubDate>Mon, 04 May 2026 04:41:20 +0000</pubDate>

<item>
<title>redityo on "Renaming Files on Upload"</title>
<link>https://www.machform.com/forums/topic/renaming-files-on-upload#post-4946</link>
<pubDate>Sat, 07 Mar 2009 14:30:49 +0000</pubDate>
<dc:creator>redityo</dc:creator>
<guid isPermaLink="false">4946@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Hi,&#60;/p&#62;
&#60;p&#62;Hmmm ... I think it will be take a lot of modification, you should edit some machform files then. Let's follow these steps :&#60;/p&#62;
&#60;p&#62;1. Edit &#34;includes/post-functions.php&#34;. go to around line  1029 ~ 1035 you will see this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;//move file and check for invalid file
$destination_file = $input[&#38;#39;machform_data_path&#38;#39;].UPLOAD_DIR.&#38;quot;/form_{$form_id}/files/{$element_name}_{$file_token}-{$record_insert_id}-{$_FILES[$element_name][&#38;#39;name&#38;#39;]}&#38;quot;;
if (move_uploaded_file($_FILES[$element_name][&#38;#39;tmp_name&#38;#39;], $destination_file)) {
	$filename = mysql_real_escape_string($_FILES[$element_name][&#38;#39;name&#38;#39;]);
	$query = &#38;quot;update ap_form_{$form_id} set $element_name=&#38;#39;{$element_name}_{$file_token}-{$record_insert_id}-{$filename}&#38;#39; where id=&#38;#39;$record_insert_id&#38;#39;&#38;quot;;
	do_query($query);
}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;replace with this&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($form_id != 25) {
	//move file and check for invalid file
	$destination_file = $input[&#38;#39;machform_data_path&#38;#39;].UPLOAD_DIR.&#38;quot;/form_{$form_id}/files/{$element_name}_{$file_token}-{$record_insert_id}-{$_FILES[$element_name][&#38;#39;name&#38;#39;]}&#38;quot;;
	if (move_uploaded_file($_FILES[$element_name][&#38;#39;tmp_name&#38;#39;], $destination_file)) {
		$filename = mysql_real_escape_string($_FILES[$element_name][&#38;#39;name&#38;#39;]);
		$query = &#38;quot;update ap_form_{$form_id} set $element_name=&#38;#39;{$element_name}_{$file_token}-{$record_insert_id}-{$filename}&#38;#39; where id=&#38;#39;$record_insert_id&#38;#39;&#38;quot;;
		do_query($query);
	}&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;2. Edit &#34;download.php&#34; file, go to around line 33. You will see this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$file_1   	= substr($filename_only,strpos($filename_only,&#38;#39;-&#38;#39;)+1);
$filename_only 	= substr($file_1,strpos($file_1,&#38;#39;-&#38;#39;)+1);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;replace with &#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($form_id == 25) {
	$file_1 	   	= $filename_only;
	$filename_only 	= $file_1;
}else {
	$file_1 	   	= substr($filename_only,strpos($filename_only,&#38;#39;-&#38;#39;)+1);
	$filename_only 	= substr($file_1,strpos($file_1,&#38;#39;-&#38;#39;)+1);
 }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;3. Edit &#34;includes/helper-functions.php&#34;, go to around line 383 and you will see this code :&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;$filename_value =  substr($filename_value,strpos($filename_value,&#38;#39;-&#38;#39;)+1);
$filename_value = substr($file_1,strpos($file_1,&#38;#39;-&#38;#39;)+1);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;replace with&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;if ($form_id == 25) {
	$file_1  	   	= $filename_value;
	$filename_only 	= $file_1;
}else {
$filename_value =  substr($filename_value,strpos($filename_value,&#38;#39;-&#38;#39;)+1);
$filename_value = substr($file_1,strpos($file_1,&#38;#39;-&#38;#39;)+1);
 }&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;I assume your form id is 25, so make sure you've adjust your form id with yours.
&#60;/p&#62;</description>
</item>
<item>
<title>BFG9000 on "Renaming Files on Upload"</title>
<link>https://www.machform.com/forums/topic/renaming-files-on-upload#post-4928</link>
<pubDate>Fri, 06 Mar 2009 17:21:23 +0000</pubDate>
<dc:creator>BFG9000</dc:creator>
<guid isPermaLink="false">4928@https://www.machform.com/forums/</guid>
<description>&#60;p&#62;Greetings All,&#60;/p&#62;
&#60;p&#62;I have a form that includes a couple of file uploads (one for .jpg &#38;#38; one for .pdf).&#60;br /&#62;
Another field on the form is for A unique identifier that the user keys in (e.g. GT5000123456).&#60;/p&#62;
&#60;p&#62;I'd like the files to be renamed on upload to GT5000123456.jpg &#38;#38; GT5000123456.pdf respectively.&#60;/p&#62;
&#60;p&#62;I'm fairly sure this is possible, but I guess I'm lloking for some assistance.....&#60;/p&#62;
&#60;p&#62;TTFN&#60;/p&#62;
&#60;p&#62;BFG
&#60;/p&#62;</description>
</item>

</channel>
</rss>
