getModule(); $parentId = $request->get('parentId'); // Required attachment Id incase if module is modcomments // to support multiple attachment $attachmentId = $request->get('attachmentId'); $parentModule = $request->get('parentModule'); $result = Vtiger_Connector::getInstance()->downloadFile($module, $request->get('recordId', array()), $parentId, $parentModule, $attachmentId); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Transfer-Encoding: binary'); header('Cache-Control: must-revalidate'); header('Content-type: '.$result['filetype']); header('Content-Disposition: attachment; filename='.$result['filename']); header('Expires: 0'); header('Pragma: public'); header('Content-Length: '.$result['filesize']); ob_clean(); flush(); echo base64_decode($result['filecontents']); } }