[-] BO : Fix bug #PSCFV-10718 AdminAttachments old file not deleted on update
This commit is contained in:
@@ -151,12 +151,15 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
);
|
||||
else
|
||||
{
|
||||
|
||||
do $uniqid = sha1(microtime());
|
||||
while (file_exists(_PS_DOWNLOAD_DIR_.$uniqid));
|
||||
if (!copy($_FILES['file']['tmp_name'], _PS_DOWNLOAD_DIR_.$uniqid))
|
||||
$this->errors[] = $this->l('Failed to copy the file.');
|
||||
$_POST['file_name'] = $_FILES['file']['name'];
|
||||
@unlink($_FILES['file']['tmp_name']);
|
||||
if (!sizeof($this->errors) && isset($a) && file_exists(_PS_DOWNLOAD_DIR_.$a->file))
|
||||
unlink(_PS_DOWNLOAD_DIR_.$a->file);
|
||||
$_POST['file'] = $uniqid;
|
||||
$_POST['mime'] = $_FILES['file']['type'];
|
||||
}
|
||||
@@ -172,11 +175,14 @@ class AdminAttachmentsControllerCore extends AdminController
|
||||
'<b>'.$upload_mb.'</b>'
|
||||
);
|
||||
}
|
||||
else if (!empty($_FILES['file']['tmp_name']))
|
||||
else
|
||||
$this->errors[] = $this->l('Upload error. Please check your server configurations for the maximum upload size allowed.');
|
||||
}
|
||||
$this->validateRules();
|
||||
}
|
||||
return parent::postProcess();
|
||||
$return = parent::postProcess();
|
||||
if (!$return && isset($uniqid) && file_exists(_PS_DOWNLOAD_DIR_.$uniqid))
|
||||
@unlink(_PS_DOWNLOAD_DIR_.$uniqid);
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user