Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: ftp download

  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post

    ftp download

    I am trying to upload a file to the user activating this link. This is missing a key element like an fputs or something?

    PHP Code:
    function planetaryorbits(){
            
    $source "/home/rubeum/public_html/PlanetaryOrbits.xlsm";
            
    $target fopen("/home/rubeum/public_html/PlanetaryOrbits.xlsm""w");
            
    $conn = @ftp_connect("ftp.webserver.com") or die("Could not connect");
            
    ftp_login($conn,"user","pass") or die("Could not login");
            
    ftp_fget($conn,$target,$source,FTP_ASCII);
            
    ftp_close($conn);
        } 

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Upload or download? You describe upload, but this one here downloads. To upload you'd use ftp_[f]put instead. It is also possible that the file as you are looking for with the path is invalid, so you'll need to check if that exists with ftp_nlist or ftp_rawlist and navigating as necessary. Actually, now that I think of it I'm not sure if you can command an ftp server to give you a file with a filepath; it may only be happy with a file name based on the pwd. And I can't test that right now either.

    The "user" in this scope would be that of the connection to ftp.webserver.com of course; you can't force an ftp connection to a client, although if they have ftp services enabled you can connect to them if you pull their ip from remote host (and if its accurate) and transfer a file that way too. That would be sandboxed into the environment that they have supplied as a valid location. I would deem that as an unreliable option, for which you should prompt them with a save dialog and serve it over http instead.

  • #3
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post
    A link from the website downloads a file using ftp from my server.

    Both paths ($source and $target) are from the root directory of my server.

    These my be incorrect.


  •  

    Posting Permissions

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