array("%" . $_GET['photo'], 'String') ); $dao = CRM_Core_DAO::executeQuery($sql, $params); while ($dao->fetch()) { $cid = $dao->id; } if ($cid) { $config = CRM_Core_Config::singleton(); $buffer = file_get_contents($config->customFileUploadDir . $_GET['photo']); $mimeType = 'image/' . pathinfo($_GET['photo'], PATHINFO_EXTENSION); CRM_Utils_System::download($_GET['photo'], $mimeType, $buffer, NULL, TRUE, 'inline' ); CRM_Utils_System::civiExit(); } else { CRM_Core_Error::fatal('Photo does not exist'); } } }