Why not use JFile::getExt($filename) with uploads
Gosling Cools
Membre junior
Posts: 20
il y a 9 ans 1 semaine #1078
par Gosling Cools
Why not use JFile::getExt($filename) with uploads a été créé par 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:Regards,
Gosling
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]);
Gosling
Connexion ou Créer un compte pour participer à la conversation.
Victor
Administrateur
Posts: 19
il y a 9 ans 5 jours #1079
par Victor
Back-end developer on Component Creator
Réponse de Victor sur le sujet 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
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
Connexion ou Créer un compte pour participer à la conversation.
Gosling Cools
Membre junior
Posts: 20
il y a 9 ans 5 jours #1080
par Gosling Cools
Réponse de Gosling Cools sur le sujet Why not use JFile::getExt($filename) with uploads
Thanks!
But now there's an error in the code.
This line:Should be
And this line:Shoud/could be:Regards,
Gosling
But now there's an error in the code.
This line:
$filename[0] = preg_replace("/[^A-Za-z0-9]/i", "-", $filename);
$filename = preg_replace("/[^A-Za-z0-9]/i", "-", $filename);
And this line:
$filename = md5(time()) . '-' . array($filename, '.', $extension);
$filename = md5(time()) . '_' . $filename . '.' . $extension;
Gosling
Connexion ou Créer un compte pour participer à la conversation.
Gosling Cools
Membre junior
Posts: 20
il y a 9 ans 5 jours #1082
par Gosling Cools
Réponse de Gosling Cools sur le sujet 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);
Connexion ou Créer un compte pour participer à la conversation.
Gosling Cools
Membre junior
Posts: 20
il y a 9 ans 5 jours #1084
par Gosling Cools
Réponse de Gosling Cools sur le sujet Why not use JFile::getExt($filename) with uploads
this line:should be
$filename = md5(time() . '-' . $filename . '.' . $extension);
$filename = md5(time()) . '-' . $filename . '.' . $extension;
Connexion ou Créer un compte pour participer à la conversation.
Victor
Administrateur
Posts: 19
il y a 9 ans 5 jours #1086
par Victor
Back-end developer on Component Creator
Réponse de Victor sur le sujet Why not use JFile::getExt($filename) with uploads
Done!
Back-end developer on Component Creator
Connexion ou Créer un compte pour participer à la conversation.
Temps de génération de la page : 0.064 secondes