Links to FTP Sites
[Previous] [Main] [Next]

 
FTP is an abbreviation for "File Transfer Protocol". FTP is used to send and receive files across the internet. You can add a hyperlink to a document that will automatically download a file to a user's computer when clicked. Such hyperlinks are nearly identical to regular hyperlinks, with the only difference being that the usual "http://" is replaced by "ftp://" in the referenced URL.  
 
Note that many FTP servers (including Unix-based systems) use case-sensitive names for files and directories.  
 
The following example shows how to use htmlHyperLink to create a hyperlink that lets a user easily download a demo of DC Micro Development's Crusher! Data Compression Toolkit.  
 
 
#include <stdio.h>  
#include <stdlib.h>  
#include <dcmicro/htmlpp/htmlpp.h>  
 
int main( void )  
{  
  htmlCgi   server ;  
  htmlPage  page( "html++ example application" ) ;  
 
  //  Create a hyperlink to the file to be downloaded,  
  //  specifying "ftp://" to indicate the FTP protocol.  
  htmlHyperLink  demo ;  
  demo.URL("ftp://ftp.dcmicro.com/pub/crusher/crdemow.exe");  
 
  //  Add the "Click here" message to the hyperlink, then  
  //  add the hyperlink to the page.  
  page << ( demo << "Click here" )  
       << " to download a demo of the Crusher! Data "  
          "Compression Toolkit." ;  
 
  server << page ;  
  return 0 ;  
}  
 
 
When executed, the above program produces the following HTML output:  
 
Content-Type: text/html  
<HTML>  
<HEAD>  
<TITLE>html++ example application</TITLE>  
</HEAD>  
<BODY>  
<A HREF="ftp://ftp.dcmicro.com/pub/crusher/crdemow.exe">Click here</A> to download a demo of the Crusher! Data Compression Toolkit.  
</BODY>  
</HTML>  
 

 

ex_hyperlink3.gif  

 
 
When the hyperlink is clicked, the user's browser will present a window prompting the user to save the file locally on their hard drive:  
 

ex_hyperlink4.gif  



©1998 DC Micro Development. All rights reserved.
No portion of this document may be c opied or reproduced without expressed written consent.
html++ is a trademark of DC Micro Development.