Sanitize image file names to remove special characters; fix existing image paths
This commit is contained in:
@@ -159,7 +159,8 @@ class ItemController
|
||||
if (!is_dir($uploadDir)) {
|
||||
mkdir($uploadDir, 0755, true);
|
||||
}
|
||||
$fileName = uniqid() . '_' . basename($file['name']);
|
||||
$safeName = preg_replace('/[^a-zA-Z0-9_\-\.]/', '_', basename($file['name']));
|
||||
$fileName = uniqid() . '_' . $safeName;
|
||||
$targetPath = $uploadDir . $fileName;
|
||||
error_log("Attempting to move from " . $file['tmp_name'] . " to " . $targetPath);
|
||||
if (move_uploaded_file($file['tmp_name'], $targetPath)) {
|
||||
|
||||
Reference in New Issue
Block a user