Powerful and easy to use cms to build websites, blogs or ecommerce stores.
HTML backendblogblog-engineblog-platformbloggingcmscontent-managementcontent-management-systemecommerceecommerce-platformno-codepage-builderphpphp-cmsphp7php8self-hostedshopping-cartweb-applicationwebsite-builder
If uploaded file already exists add a random name in the name to avoid overwritting
givanz98a0268d8652
diff --git a/admin/controller/media/media.php b/admin/controller/media/media.phpindex e1f5caa..3e74aeb 100755--- a/admin/controller/media/media.php+++ b/admin/controller/media/media.php@@ -70,7 +70,7 @@ class Media extends Base {$path = sanitizeFileName($this->request->post['mediaPath']);$file = $this->request->files['file'];$fileName = sanitizeFileName($file['name']);- $path = str_replace(['/media', '/public/media'], '', $path);+ $path = preg_replace('@^/public/media|^/media|^/public@', '', $path);$extension = strtolower(substr($fileName, strrpos($fileName, '.') + 1));if (in_array($extension, $this->uploadDenyExtensions)) {@@ -91,12 +91,16 @@ class Media extends Base {default:die(__('Unknown errors.'));}-- $destination = DIR_MEDIA . $path . '/' . $fileName;++ $origFilename = $fileName;+ $i = 1;+ while (file_exists($destination = DIR_MEDIA . $path . DS . $fileName) && ($i++ < 5)) {+ $fileName = rand(0, 10000) . '-' . $origFilename;+ };if (move_uploaded_file($file['tmp_name'], $destination)) {if (isset($this->request->post['onlyFilename'])) {- echo $file['name'];+ echo $fileName;} else {echo $destination;}