mirror of
https://github.com/getgrav/grav.git
synced 2026-07-06 10:48:29 +02:00
FlexMediaTrait: Cropping existing image without original fails to move the original image to safe place
This commit is contained in:
@@ -125,6 +125,11 @@ trait FlexMediaTrait
|
||||
}
|
||||
if ($uploadedFile->getError() === \UPLOAD_ERR_OK) {
|
||||
$uploadedFile->moveTo($filepath);
|
||||
} elseif (!file_exists($filepath) && $pos = strpos($filename, '/')) {
|
||||
$origpath = sprintf('%s/%s', $path, substr($filename, $pos));
|
||||
if (file_exists($origpath)) {
|
||||
copy($origpath, $filepath);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$uploadedFile->moveTo($filepath);
|
||||
@@ -172,7 +177,6 @@ trait FlexMediaTrait
|
||||
}
|
||||
|
||||
if (file_exists($targetFile)) {
|
||||
|
||||
$result = unlink($targetFile);
|
||||
if (!$result) {
|
||||
throw new RuntimeException($language->translate('PLUGIN_ADMIN.FILE_COULD_NOT_BE_DELETED') . ': ' . $filename, 500);
|
||||
|
||||
Reference in New Issue
Block a user