Sanitize image file names to remove special characters; fix existing image paths
This commit is contained in:
parent
b1ce2ce3aa
commit
e1cf2a3e46
Binary file not shown.
|
Before Width: | Height: | Size: 281 KiB After Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 218 KiB After Width: | Height: | Size: 218 KiB |
@ -159,7 +159,8 @@ class ItemController
|
|||||||
if (!is_dir($uploadDir)) {
|
if (!is_dir($uploadDir)) {
|
||||||
mkdir($uploadDir, 0755, true);
|
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;
|
$targetPath = $uploadDir . $fileName;
|
||||||
error_log("Attempting to move from " . $file['tmp_name'] . " to " . $targetPath);
|
error_log("Attempting to move from " . $file['tmp_name'] . " to " . $targetPath);
|
||||||
if (move_uploaded_file($file['tmp_name'], $targetPath)) {
|
if (move_uploaded_file($file['tmp_name'], $targetPath)) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user