Skip to content

Commit

Permalink
Update ps_imageslider.php
Browse files Browse the repository at this point in the history
Converted the file name using `Tools::str2url()`
  • Loading branch information
Codencode committed Nov 25, 2024
1 parent a6f6125 commit 0b78fa9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ps_imageslider.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,17 +514,18 @@ protected function _postProcess()
) {
$temp_name = tempnam(_PS_TMP_IMG_DIR_, 'PS');
$salt = sha1(microtime());
$file_name = Tools::str2url($_FILES['image_' . $language['id_lang']]['name']) . $type;
if ($error = ImageManager::validateUpload($_FILES['image_' . $language['id_lang']])) {
$errors[] = $error;
} elseif (!$temp_name || !move_uploaded_file($_FILES['image_' . $language['id_lang']]['tmp_name'], $temp_name)) {
return false;
} elseif (!ImageManager::resize($temp_name, __DIR__ . '/images/' . $salt . '_' . $_FILES['image_' . $language['id_lang']]['name'], null, null, $type)) {
} elseif (!ImageManager::resize($temp_name, __DIR__ . '/images/' . $salt . '_' . $file_name, null, null, $type)) {
$errors[] = $this->displayError($this->trans('An error occurred during the image upload process.', [], 'Admin.Notifications.Error'));
}
if (file_exists($temp_name)) {
@unlink($temp_name);
}
$slide->image[$language['id_lang']] = $salt . '_' . $_FILES['image_' . $language['id_lang']]['name'];
$slide->image[$language['id_lang']] = $salt . '_' . $file_name;
} elseif (Tools::getValue('image_old_' . $language['id_lang']) != '') {
$slide->image[$language['id_lang']] = Tools::getValue('image_old_' . $language['id_lang']);
}
Expand Down

0 comments on commit 0b78fa9

Please sign in to comment.