Thread: Ftpdownload

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    59
    Rep Power
    0

    Ftpdownload


    My webserver has an ftp section in it. I am trying to make an Excel file available for download. Where an I going wrong?
    Code:
    <?php
    session_start();
    	function ftpdownload(){
    		$source = "name@webserver.com/ftpfilepath/file.xlsm";
    		$target = fopen("c:/file.xlsm", "w");
    		$conn = ftp_connect("ftp.webserver.com") or die("Could not connect");
    		ftp_login($conn,"name@webserver.com","pass");
    		ftp_fget($conn,$target,$source,FTP_ASCII);
    		ftp_close($conn);
    	}
    
    session_write_close();	
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/"xhtmll/DTD/xhtmll-strict.dtd">
    ...
    <div class = "content" id ="download">
            <h2><a href="<?php echo $_SESSION['ftpdownload']; ?>">file.xlsm</a></h2>
    </div>
  2. #2
  3. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    59
    Rep Power
    0
    Yes by user. I am not certain this will work. My webhost makes ftp site available but I am sure how the user actually can download the file.
    Last edited by Philosophaie; April 30th, 2012 at 01:07 AM.
  6. #4
  7. Did you steal it?
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    13,997
    Rep Power
    9397
    You can't download it for them. They have to choose to do so by visiting the file directly (and then their browser will do what it wants).

    I'm pretty sure every single major browser supports (read-only) FTP access. Just give them an FTP link.
    Code:
    <a href="ftp://webserver.com/ftpfilepath/file.xslm">file.xslm</a>

IMN logo majestic logo threadwatch logo seochat tools logo