private function processUploadedFile($fileInputName, $type)
 {
     if (empty($_FILES) || !isset($_FILES[$fileInputName])) {
         self::sendResponse(array('success' => false, 'message' => 'No file found!'));
     }
     $file = $_FILES[$fileInputName];
     if ($file['error'] > 0) {
         self::sendResponse(array('success' => false, 'message' => $file['error']));
     }
     if ($type == 'image' && !Validation::isValidImage($file) || $type == 'video' && !Validation::isValidVideo($file) || $type == 'audio' && !Validation::isValidAudio($file)) {
         self::sendResponse(array('success' => false, 'message' => 'File type is invalid!'));
     }
     $temp = explode('.', $file['name']);
     $targetFolder = implode(DS, array($this->app->config['app']['media_path'], date('Y'), date('m'), date('d')));
     $fs = new Filesystem();
     try {
         $fs->mkdir($targetFolder);
     } catch (IOExceptionInterface $e) {
         $this->app->log->getWriter()->write('An error occurred while creating your directory at ' . $e->getPath(), \Slim\Log::ERROR);
     }
     if (!$fs->exists($targetFolder)) {
         $this->sendOperationFailedResult('File');
     }
     $hashFileName = base64_encode(date('Ymdhis') . uniqid());
     $rtn = array('Extention' => end($temp), 'RawFileName' => $file['name'], 'HashFileName' => $hashFileName, 'FileTmpPath' => $file['tmp_name'], 'Url' => implode('/', array($this->app->config['app']['asset_base_url'], 'media', date('Y'), date('m'), date('d'), $hashFileName . '.' . end($temp))));
     $fileTargetPath = implode(DS, array($this->app->config['app']['media_path'], date('Y'), date('m'), date('d'), $rtn['HashFileName'] . '.' . $rtn['Extention']));
     move_uploaded_file($rtn['FileTmpPath'], $fileTargetPath);
     if ($type == 'image') {
         $imagine = new Imagine();
         $image = $imagine->open($fileTargetPath);
         $image->thumbnail(new Box(180, 180))->save(str_replace('.' . $rtn['Extention'], '_180x180.' . $rtn['Extention'], $fileTargetPath));
         $rtn['ThumbUrl'] = implode('/', array($this->app->config['app']['asset_base_url'], 'media', date('Y'), date('m'), date('d'), $rtn['HashFileName'] . '_180x180.' . $rtn['Extention']));
     }
     return $rtn;
 }