Randi Ardiansyah
<?php
include_once('dbClass.php');
$db = new CdbClass;
if (isset($_REQUEST['NOMORKLAIM'])){
$dir = dirname(__FILE__);
$NOMORKLAIM=$_REQUEST['NOMORKLAIM'];
$db->connect() ;
$sql="select top 100 * from [RPT_ADMEDIKA_KLAIM_SOFTFILE]
where nomorklaim='".$NOMORKLAIM."'";
$result = $db->execute($sql) ;
while($data = $db->fetchrow($result)){
$tglFolder = $data['TANGGAL_SUBMISSION'];
$folder = $data['BATCH_ID'];
$fileName = $data['NAMAFILE'];
}
$streamFile =$tglFolder."/".$folder."/".$fileName.".pdf";
$url = $_SERVER['PHP_SELF'];
preg_match("^[/].+[/]^",
$url, $matches);
$host0 = $matches[0];
$host1 = $matches[1];
$files="/PDF/GenerateSoftFile.pdf";
$stream ="/NON/SOFTCOPY_SCAN_DOC/".$streamFile;
$handle = fopen($dir.$files,'w');
$ftp = ftp_connect('test.co.id');
$login_result = ftp_login($ftp, 'test1213, '*****');
if(!$login_result){
echo "gagal Login";
}else{
echo "berhasil Login";
}
$exec =ftp_fget($ftp, $handle, $stream,FTP_BINARY);
if ($exec) {
echo "successfully written to $host0.$files \n";
// echo '<img src="'.$host0.$files.'" />';
echo '<embed src="'.$host0.$files.'"width="100%" height="100%"/>';
} else {
echo "There was a problem while downloading\n";
}
ftp_close($ftp);
fclose($handle);
}
else {
var_dump("false");
};