Why not use JFile::getExt($filename) with uploads
Gosling Cools
Junior Member
Posts: 20
9 år 1 dag dager siden #1078
av Gosling Cools
Why not use JFile::getExt($filename) with uploads opprettet av 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
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Victor
Administrator
Posts: 19
8 år 11 måneder dager siden #1079
av Victor
Back-end developer on Component Creator
Besvart av Victor i emne 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
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Gosling Cools
Junior Member
Posts: 20
8 år 11 måneder dager siden #1080
av Gosling Cools
Besvart av Gosling Cools i emne 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
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Gosling Cools
Junior Member
Posts: 20
8 år 11 måneder dager siden #1082
av Gosling Cools
Besvart av Gosling Cools i 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);
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Gosling Cools
Junior Member
Posts: 20
8 år 11 måneder dager siden #1084
av Gosling Cools
Besvart av Gosling Cools i emne Why not use JFile::getExt($filename) with uploads
this line:should be
$filename = md5(time() . '-' . $filename . '.' . $extension);
$filename = md5(time()) . '-' . $filename . '.' . $extension;
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Victor
Administrator
Posts: 19
8 år 11 måneder dager siden #1086
av Victor
Back-end developer on Component Creator
Besvart av Victor i emne Why not use JFile::getExt($filename) with uploads
Done!
Back-end developer on Component Creator
Vennligst Logg inn eller Registrer konto for å bli med i samtalen.
Tid til å lage siden: 0.051 sekunder