check if file really exist before add/remove it
This commit is contained in:
parent
a56f2ec183
commit
aa9ffd119a
2 changed files with 12 additions and 4 deletions
|
@ -2,6 +2,11 @@
|
|||
|
||||
OCP\JSON::checkAppEnabled('files_external');
|
||||
|
||||
if ( !($filename = $_FILES['rootcert_import']['name']) ) {
|
||||
header("Location: settings/personal.php");
|
||||
exit;
|
||||
}
|
||||
|
||||
$fh = fopen($_FILES['rootcert_import']['tmp_name'], 'r');
|
||||
$data = fread($fh, filesize($_FILES['rootcert_import']['tmp_name']));
|
||||
fclose($fh);
|
||||
|
|
|
@ -5,7 +5,10 @@ OCP\JSON::checkLoggedIn();
|
|||
OCP\JSON::callCheck();
|
||||
|
||||
$view = \OCP\Files::getStorage("files_external");
|
||||
$cert = ltrim($_POST['cert'], "/\\.");
|
||||
$file = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath("").'uploads/'.$cert;
|
||||
unlink($file);
|
||||
OC_Mount_Config::createCertificateBundle();
|
||||
$file = 'uploads/'.ltrim($_POST['cert'], "/\\.");
|
||||
|
||||
if ( $view->file_exists($file) ) {
|
||||
$view->unlink($file);
|
||||
OC_Mount_Config::createCertificateBundle();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue