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

8 года 5 мес. назад #1078 от Gosling Cools
Gosling Cools создал тему: Why not use JFile::getExt($filename) with uploads
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

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

8 года 5 мес. назад #1079 от Victor
Victor ответил в теме Why not use JFile::getExt($filename) with uploads
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

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

8 года 5 мес. назад #1080 от Gosling Cools
Gosling Cools ответил в теме 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

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

8 года 5 мес. назад #1082 от Gosling Cools
Gosling Cools ответил в теме 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);
:-)

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

8 года 5 мес. назад #1084 от Gosling Cools
Gosling Cools ответил в теме Why not use JFile::getExt($filename) with uploads
this line:
$filename = md5(time() . '-' . $filename . '.' . $extension);
should be
$filename = md5(time()) . '-' . $filename . '.' . $extension;

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

8 года 5 мес. назад #1086 от Victor
Victor ответил в теме Why not use JFile::getExt($filename) with uploads
Done! :)

Back-end developer on Component Creator

Пожалуйста Войти или Регистрация, чтобы присоединиться к беседе.

Время создания страницы: 0.162 секунд
Работает на Kunena форум

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.