When files are being uploaded, the timestamp appears in the extension. Is there a way to make it appear before the filename instead?
This code will add the date before the filename and keeps the extension intact.
In Build 730 and higher, open the following file:
/components/com_breezingforms/facileforms.process.php
Look for:
line 3821 (normal upload)
$path = $baseDir.'/'.$userfile_name; if ($timestamp) $path .= '.'.date('YmdHis'); if (file_exists($path)) { $rnd = md5( mt_rand(0, mt_getrandmax()) ); $path = $baseDir.'/'.$rnd.'_'.$userfile_name; if ($timestamp) $path .= '.'.date('YmdHis'); if (file_exists($path)) { $this->status = _FF_STATUS_UPLOAD_FAILED; $this->message = BFText::_('PROCESS_FILEEXISTS'); return ''; } } // if
Replace it with:
if ($timestamp) $time_path = date('YmdHis')."_"; $path = $baseDir.'/'.$time_path.$userfile_name; if (file_exists($path)) { $this->status = _FF_STATUS_UPLOAD_FAILED; $this->message = BFText::_('PROCESS_FILEEXISTS'); return ''; } // if
Next, find:
line 3916 (flash upload)
$path = $baseDir.'/'.$userfile_name; if ($row->flag1) $path .= '.'.date('YmdHis'); if (file_exists($path)) { $rnd = md5( mt_rand(0, mt_getrandmax()) ); $path = $baseDir.'/'.$rnd.'_'.$userfile_name; if ($row->flag1) $path .= '.'.date('YmdHis'); if (file_exists($path)) { $this->status = _FF_STATUS_UPLOAD_FAILED; $this->message = BFText::_('PROCESS_FILEEXISTS'); return ''; } } // if
Replace it with:
if ($row->flag1) $time_path = date('YmdHis')."_"; $path = $baseDir.'/'.$time_path.$userfile_name; if (file_exists($path)) { $this->status = _FF_STATUS_UPLOAD_FAILED; $this->message = BFText::_('PROCESS_FILEEXISTS'); return ''; } // if
Thanks to Stefan Mortelmans for contributing the code!