Why not use JFile::getExt($filename) with uploads

9 år 2 uger siden #1078 af Gosling Cools
Why not use JFile::getExt($filename) with uploads blev oprettet af Gosling Cools
Hi,

Is there a reason why you don't use JFile::getExt($filename) and JFile::stripExt($filename) in the \tables\XXXXX.php files?
For instance a filename with multiple dots will explode wrongly with your code:
//Replace any special characters in the filename
                  $filename = explode('.', $file['name']);
                  $filename[0] = preg_replace("/[^A-Za-z0-9]/i", "-", $filename[0]);
Regards,

Gosling

Venligst Log på eller Opret en konto for at deltage i samtalen

9 år 1 uge siden #1079 af Victor
Hi Gosling,

Thank you for pointing out this issue. We have patched our system to use Joomla functions instead of PHP ones.

Best regards,

Víctor

Back-end developer on Component Creator

Venligst Log på eller Opret en konto for at deltage i samtalen

9 år 1 uge siden #1080 af Gosling Cools
Besvaret af Gosling Cools på emne Why not use JFile::getExt($filename) with uploads
Thanks!

But now there's an error in the code.

This line:
$filename[0] = preg_replace("/[^A-Za-z0-9]/i", "-", $filename);
Should be
$filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename);

And this line:
$filename = md5(time()) . '-' . array($filename, '.', $extension);
Shoud/could be:
$filename = md5(time()) . '_' . $filename . '.' . $extension;
Regards,

Gosling

Venligst Log på eller Opret en konto for at deltage i samtalen

9 år 1 uge siden #1082 af Gosling Cools
Besvaret af Gosling Cools på emne Why not use JFile::getExt($filename) with uploads
And now remove the last ) please in:
//Add Timestamp MD5 to avoid overwriting
$filename = md5(time()) . '-' . $filename . '.' . $extension);
:-)

Venligst Log på eller Opret en konto for at deltage i samtalen

9 år 1 uge siden #1084 af Gosling Cools
Besvaret af Gosling Cools på emne Why not use JFile::getExt($filename) with uploads
this line:
$filename = md5(time() . '-' . $filename . '.' . $extension);
should be
$filename = md5(time()) . '-' . $filename . '.' . $extension;

Venligst Log på eller Opret en konto for at deltage i samtalen

9 år 1 uge siden #1086 af Victor
Done! :)

Back-end developer on Component Creator

Venligst Log på eller Opret en konto for at deltage i samtalen

Tid til at oprette siden: 0.052 sekunder
Leveret af Kunena Forum

Vi we benytter cookies, så vi bedst muligt kan levere vores services. For mere information, se vores