Skip to content

Commit

Permalink
Create and update folder in admin dashboard validate .php extension i…
Browse files Browse the repository at this point in the history
…mage: uvdesk#218
  • Loading branch information
Abhi12-gupta committed May 26, 2023
1 parent d99e8a4 commit 60eea8a
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Controller/Folder.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,25 @@ public function createFolder(Request $request)

return $this->redirect($this->generateUrl('helpdesk_member_knowledgebase_create_folder'));
}

if (strpos($imageFile->getClientOriginalName(), '.php') !== false) {
$message = $this->translator->trans('Warning! Provide valid image file. (Recommened: PNG, JPG or GIF Format).');
$this->addFlash('warning', $message);

return $this->redirect($this->generateUrl('helpdesk_member_knowledgebase_create_folder'));
}
}

$data = $request->request->all();
$folder->setName($data['name']);
$folder->setDescription($data['description']);
$folder->setvisibility($data['visibility']);
if(isset($solutionImage)){

if (isset($solutionImage)) {
$assetDetails = $this->fileSystem->getUploadManager()->uploadFile($solutionImage, 'knowledgebase');
$folder->setSolutionImage($assetDetails['path']);
}

$folder->setDateAdded( new \DateTime());
$folder->setDateUpdated( new \DateTime());
$folder->setSortOrder(1);
Expand Down Expand Up @@ -124,7 +133,7 @@ public function updateFolder($folderId)
$solutionImage = $request->files->get('solutionImage');

if ($imageFile = $request->files->get('solutionImage')) {

if ($imageFile->getMimeType() == "image/svg+xml" || $imageFile->getMimeType() == "image/svg") {
if (!$this->fileUploadService->svgFileCheck($imageFile)){
$message = $this->translator->trans('Warning! Not a vaild svg. (Recommened: PNG, JPG or GIF Format).');
Expand All @@ -142,8 +151,17 @@ public function updateFolder($folderId)
'folder' => $folder
]);
}

if (strpos($imageFile->getClientOriginalName(), '.php') !== false) {
$message = $this->translator->trans('Warning! Provide valid image file. (Recommened: PNG, JPG or GIF Format).');
$this->addFlash('warning', $message);

return $this->redirect($this->generateUrl('helpdesk_member_knowledgebase_folders_collection'));
}
}

$formData = $request->request->all();

if (isset($solutionImage)) {
// Removing old image from physical path is new image uploaded
$fileService = new Fileservice();
Expand Down

0 comments on commit 60eea8a

Please sign in to comment.