I have a project that requires I retrieve document(s) from a remote server via TCP/IP and the following script seems to allllmost work:
The issue I am running into is that PHP opens the file and then displays it's binary garbage in the browser screen.
how can i actually retrieve/download the file rather than just display its contents to the browser? I cannot use ftp, sftp, scp due to the custom app that I am connecting to (written in delphi and running on a windows server)
<?php
set_magic_quotes_runtime(false);
$fp = fsockopen("xxx.xxx.xxx.xxx", 6000, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
$out = "USER=username=";
$out .= "18=GET=filename.tif";
fwrite($fp, $out);
while (!feof($fp)) {
echo fgets($fp, 128);
//fgets($fp, 128);
//fread($fp, 1024);
//readfile($fp);
//fopen($fp, "r");
//file($fp);
//file_get_contents($fp);
}
fclose($fp);
}
?>
as you can see i have tried other file manipulation functions with no luck but using sockets and doing file functions is new to me so I am hoping someone out there has done this before or may have some insights