/** @var \wcf\system\file\upload\UploadFile $file */
$file = $this->parameters['uploads'][$type];
- if ($style->getVariable($type) && file_exists($style->getAssetPath().basename($style->getVariable($type)))) {
- if (!$file || $style->getAssetPath().basename($style->getVariable($type)) !== $file->getLocation()) {
- unlink($style->getAssetPath().basename($style->getVariable($type)));
- }
- }
-
- if ($file !== null) {
+ // Only save file, if it is not proccessed.
+ if ($file !== null && !$file->isProcessed()) {
$fileLocation = $file->getLocation();
$extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
- $newName = $type.'-'.\bin2hex(\random_bytes(4)).'.'.$extension;
+ $newName = $type.'-'.Hex::encode(\random_bytes(4)).'.'.$extension;
$newLocation = $style->getAssetPath().$newName;
rename($fileLocation, $newLocation);
$this->parameters['variables'][$type] = $newName;