connect()) { $ftp->login($user,$password); $sock = $ftp->retr(trim($filename)); if($sock) { if($sock) { $mime_type = (strstr($HTTP_USER_AGENT,'IE') || strstr($HTTP_USER_AGENT,'OPERA')) ? 'application/octetstream' : 'application/octet-stream'; // finally send the headers and the file header('Content-Type: ' . $mime_type); header('Expires: ' . $now); if (strstr($HTTP_USER_AGENT,'IE')) { header('Content-Disposition: inline; filename="' . $filename. '"'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); } else { header('Content-Disposition: attachment; filename="' . $filename .'"'); header('Pragma: no-cache'); } fpassthru($sock); exit(); } } else { echo 'file could not be retrieved'; } } else { echo 'Could not connect'; }