5
you can change the filenames XOOPS saves images with.
See class/uploader.php for options here...
if (isset($this->targetFileName)) {
$this->savedFileName = $this->targetFileName;
} elseif (isset($this->prefix)) {
$this->savedFileName = uniqid($this->prefix).'.'.strtolower($matched[1]);
} else {
$this->savedFileName = strtolower($this->mediaName);
}
use it something like this...
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $imgcat->getVar('imgcat_maxsize'), $imgcat->getVar('imgcat_maxwidth'), $imgcat->getVar('imgcat_maxheight'));
$uploadedFilename = $_FILES['image_file']['name'];
$uploader->setTargetFileName('myprefix_'.$uploadedFilename);
if ($uploader->fetchMedia($xoops_upload_file[0])) {
if (!$uploader->upload()) {
$err = $uploader->getErrors();
but you really should introduce a random element somewhere as well in case someone finds a way to upload a unsafe file.. makes it harder for them to find it on the server. I think the current system is there to prevent users over-writing each others files so you may want to keep that in mind as well.