pquery($query, array($fid, $encFileName)); if ($result && $db->num_rows($result)) { $resultData = $db->fetch_array($result); $fileId = $resultData['attachmentsid']; $filePath = $resultData['path']; $fileName = $resultData['name']; $storedFileName = $resultData['storedname']; $fileType = $resultData['type']; $sanitizedFileName = sanitizeUploadFileName($fileName, $upload_badext); /** * While saving the document applying decode_html to save in DB, but this is not happening for the images * This save happens from mailroom, inbox, record save, document save etc.. */ if (!empty($encFileName)) { if(!empty($storedFileName)){ $finalFilePath = $filePath.$fileId.'_'.$storedFileName; }else if(is_null($storedFileName)){ $finalFilePath = $filePath.$fileId.'_'.$encFileName; } $isFileExist = false; if (file_exists($finalFilePath)) { $isFileExist = true; } else { $finalFilePath = $filePath.$fileId.'_'.$sanitizedFileName; if (file_exists($finalFilePath)) { $isFileExist = true; } } if ($isFileExist) { Vtiger_ShowFile_Helper::show($finalFilePath,$fileType); } } } } /** * Function to show images out side of CRM * @param type $finalFilePath - the proper image folder path * @param type $fileType - image file type */ static function show($finalFilePath, $fileType) { $handle = fopen($finalFilePath, "rb"); $contents = fread($handle, filesize($finalFilePath)); fclose($handle); header("Content-Type: $fileType;charset=UTF-8"); echo $contents; } }