SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Download a file using ftp

    I want to be able to download a file to a person who is accessing my website. My question is: I have a webserver that has a public_ftp folder ("http://www.webserver.com/path/public_ftp/source.txt"). Would that be the same as "ftp.testftp.com" listed below?


    Code:
    <?php
    $conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
    ftp_login($conn,"admin","ert456");
    
    echo ftp_get($conn,"C://target.txt","source.txt",FTP_ASCII);
    
    ftp_close($conn);
    ?>

  2. #2
    SitePoint Zealot
    Join Date
    Sep 2010
    Posts
    131
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I also found this. Which is better?

    Code:
    <?php
    $source = "source.txt";
    $target = fopen("target.txt", "w");
    
    $conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
    ftp_login($conn,"admin","ert456");
    
    ftp_fget($conn,$target,$source,FTP_ASCII);
    
    ftp_close($conn);
    ?>

  3. #3
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    71 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Philosophaie View Post
    I want to be able to download a file to a person who is accessing my website.

    My question is: I have a webserver that has a public_ftp folder ("http://www.webserver.com/path/public_ftp/source.txt"). Would that be the same as "ftp.testftp.com" listed below?


    Code:
    <?php
    $conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
    ftp_login($conn,"admin","ert456");
    
    echo ftp_get($conn,"C://target.txt","source.txt",FTP_ASCII);
    
    ftp_close($conn);
    ?>
    I dont... quite think you've got the idea of how PHP works.

    You cannot put files onto another person's computer using PHP, unless THEY are running an FTP server. If you could, people would be force-fed viruses so often that the internet would cease to exist. PHP does not execute on the user's machine; it executes on the server.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •