Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 38 additions & 1 deletion src/FileManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,22 @@ public function paste($disk, $path, $clipboard)
*/
public function rename($disk, $newName, $oldName)
{
if(!$this->AllowTypes($newName)){
return [
'result' => [
'status' => 'error',
'message' => "Failed to rename the file because extension is not allowed",
],
];
}


Storage::disk($disk)->move($oldName, $newName);

return [
'result' => [
'status' => 'success',
'message' => 'renamed',
'message' => "renamed",
],
];
}
Expand Down Expand Up @@ -421,6 +431,16 @@ public function createDirectory($disk, $path, $name)
*/
public function createFile($disk, $path, $name)
{

if(!$this->AllowTypes($name)){
return [
'result' => [
'status' => 'error',
'message' => "Failed to create file because extension is not allowed",
],
];
}

// path for new file
$path = $this->newPath($path, $name);

Expand Down Expand Up @@ -502,4 +522,21 @@ public function streamFile($disk, $path)
return Storage::disk($disk)
->response($path, $filename, ['Accept-Ranges' => 'bytes']);
}


private function AllowTypes($name){
$ext=explode('.',$name);
$ext=end($ext);

if ($this->configRepository->getAllowFileTypes()
&& !in_array(
$ext,
$this->configRepository->getAllowFileTypes()
)
){
return false;
}else{
return true ;
}
}
}