Quick PHP FTP help

Discussion in 'PHP' started by cpufreak3, Feb 6, 2008.

  1. #1
    I'm trying to use the ftp_connect in PHP, but would like to change the port.

    Here's what I have ftp_connect('www.blockfilter.info', 22);

    However, it doesn't work. I can connect without the port number, and I know I have sftp access. I think my formatting may be wrong. Thanks

    EDIT: Let me clarify, I would like to connect via SFTP in PHP, how exactly do I do this?
     
    cpufreak3, Feb 6, 2008 IP
  2. webwurks

    webwurks Well-Known Member

    Messages:
    126
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    118
    #2
    The server you are attempting to connect with must be configured to accept ftp connections on the port (22) you wish to use before you can connect to it.
    Typically FTP access is set up for port 21
     
    webwurks, Feb 6, 2008 IP
  3. cpufreak3

    cpufreak3 Well-Known Member

    Messages:
    346
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #3
    Figured it out, I needed a PHP extension for SFTP.
     
    cpufreak3, Feb 6, 2008 IP
  4. Richard R

    Richard R Peon

    Messages:
    42
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    <?php
    // configuration
    $host = "www.blockfilter.info";
    $port = 21;
    
    // connect or die.
    ftp_connect($host, $port) or die("Could not connect to $host");
    
    ?>
    Code (markup):
    If you would like something a little more advance, send me a PM.

    edit: i see you resolved it, hadn't refreshed.
     
    Richard R, Feb 6, 2008 IP
  5. cpufreak3

    cpufreak3 Well-Known Member

    Messages:
    346
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #5
    No problem, thanks for the help, though.
     
    cpufreak3, Feb 6, 2008 IP