Display pdf without downloading on local m/c

Insoftservice
Insoftservice used Ask the Experts™
on
I want to display pdf without downloading the pdf on local server in fancy box.
<?php
	
	$ftp_server="serverip";
	$ftp_user_name = "username"; 
	$ftp_user_pass = "password";
	$conn_id = ftp_connect($ftp_server); 
	$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
	ftp_pasv($conn_id, TRUE);
	
	if ((!$conn_id)) { 
		echo "FTP connection failed";
		exit; 
	} 
	else {
		//echo "Connected to $ftp_server";
	}
	//$list=ftp_nlist($conn_id, "");
	foreach (ftp_nlist($conn_id, "") as $element) 
	{
		echo "<a class='fancypdf' data-fancybox-type='iframe' href='ftp://varun:varun123@serverip/$element'>". $element ."</a></br>";
	}
	
	
	
	
	
	
	ftp_close($conn_id);
?>
<html>
<head>
	<script type="text/javascript" src="fancybox/lib/jquery-1.10.1.min.js"></script>
	<script type="text/javascript" src="fancybox/source/jquery.fancybox.js?v=2.1.5"></script>
	<link rel="stylesheet" type="text/css" href="fancybox/source/jquery.fancybox.css?v=2.1.5" media="screen" />
	
	<script type="text/javascript">
		$(document).ready(function(){
			$(".fancypdf").fancybox({
                'frameWidth': 680,
                'frameHeight':495,
                'overlayShow':true,
                'hideOnContentClick':false,
                'type':'iframe'
			});
		});
	</script>
</head>
</html>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016
Commented:
Anything and everything that is displayed on a computer screen has been downloaded to the computer, full stop.  It may be deleted later, by the client, but if it's ever visible that is because it has been downloaded and displayed.  If you want it to be displayed it must be downloaded.  If you do not want it stolen, copied, repurposed, modified or retransmitted, do not put it online at all.  This is not a fancybox issue - it's just the way all client/server systems work.

Author

Commented:
Do you mean to say @ray that above method is downloading on local server and later deleting it.
If yes then can where actually its saving on client mc

sorry my mistake it gets stores on the server where script is written please correct me if i am wrong. I hope even if it gets downloaded on server side it has no issue thx.
Jim RiddlesPrepress/OMS Specialist
Commented:
It sounds like there might be a mis-communication here.  I believe you simply want to display links to PDFs without actually having the PDFs on your local server that is serving the web page.  Is that correct?

If so, then what you have written should work as you are expecting.  Your code connects to a FTP server, retrieves the list of available files and creates an anchor element with a reference to that file.

If, however, you are trying to prevent your end-users from downloading the PDF and only viewing it in their browser, then Ray is correct, and that won't work with your solution.

Author

Commented:
thx

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial