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!

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!