มันขึ้นข้อความนี้มา
Fatal error: Uncaught exception 'com_exception' with message '<b>Source:</b> SAP Crystal Reports ActiveX Designer<br/><b>Description:</b> Invalid directory. Details: error' in D:\AppServ\www\cs\qca_ad\ViewReportQCA.php:17 Stack trace: #0 D:\AppServ\www\cs\qca_ad\ViewReportQCA.php(17): variant->OpenReport('D:\AppServ\www\...', 1) #1 {main} thrown in D:\AppServ\www\cs\qca_ad\ViewReportQCA.php on line 17
<?php
$P_ID=$_GET["P_ID"];
$i_project=$_GET["i_project"];
$rptName=$_GET["c_filename"];
//echo("$p_id,$i_project,$c_filename");
// ตั้งชื่อไฟล์ PDF
$fileName= $_GET["P_ID"].basename($rptName,".rpt").".pdf";
$rptName=getcwd()."\\report\\$rptName";
// ลบไฟล์
if(file_exists (getcwd()."\\pdf\\".$fileName))
unlink(getcwd()."\\pdf\\".$fileName);
$o_CrObjectFactory = new COM("CrystalReports11.ObjectFactory.1");
$o_CrApplication = $o_CrObjectFactory->CreateObject("CrystalDesignRunTime.Application");
com_load_typelib("CrystalDesignRunTime.Application");
$o_CrReport = $o_CrApplication->OpenReport($rptName, 1); // 1 == crOpenReportByTempCopy.
$o_CrReport->Database->Tables->Item(1)->ConnectionProperties['User ID'] = 'sa';
$o_CrReport->Database->Tables->Item(1)->ConnectionProperties['Password'] = 'C1m2c3pass';
//echo($save_date);
//Assign the parameters to the report.
$m_Stuff = new Variant();
$o_CrIDocParam =$o_CrReport->ParameterFields->GetItemByName('@P_ID', $m_Stuff);
$o_CrIDocParam->ClearCurrentValueAndRange();
$o_CrIDocParam->AddCurrentValue($_GET["P_ID"]);
$m_Stuff2 = new Variant();
$o_CrIDocParam =$o_CrReport->ParameterFields->GetItemByName('@i_project', $m_Stuff2);
$o_CrIDocParam->ClearCurrentValueAndRange();
$o_CrIDocParam->AddCurrentValue($Topic_ID);
// Don't tell anyone what is going on when running live.
$o_CrReport->DisplayProgressDialog = false;
$path="pdf/".$fileName;
$s_ExportedReport = getcwd()."\\pdf\\".$fileName;
// Run the report and save the PDF to disk.
$o_CrReport->ExportOptions->DiskFileName = $s_ExportedReport;
$o_CrReport->ExportOptions->PDFExportAllPages = true;
$o_CrReport->ExportOptions->DestinationType = 1; // Export to File
$o_CrReport->ExportOptions->FormatType = 31; // 31 = PDF, 36 = XLS, 14 =DOC
//$o_CrReport->DiscardSavedData;
$o_CrReport->ReadRecords();
$o_CrReport->Export(false);
ob_start();
header("Pragma: public"); // required
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false); // required for certain browsers
header("Content-Type: application/pdf");
header("Content-Disposition: inline; filename=".$fileName.";" );
header("Content-Length: ".filesize($s_ExportedReport));
readfile($s_ExportedReport);
// ลบไฟล์
//if(file_exists (getcwd().'\\pdf\\'.$fileName))
//unlink(getcwd().'\\pdf\\'.$fileName);
$o_CrReport = null;
$o_CrReport = null;
$o_CrObjectFactory = null;
ob_end_flush();
?>