SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    connect_ftp does not work!

    I am developping a Joomla website and need to add an upload form to it.
    Uploaded files must go to FTP server of my company instead of going to the Web server.
    I started testing with FTP connection using ftp_connect, but it gives me an error "The website cannot display the page" on IE and blank page on FireFox.

    Here's my code.

    <?php

    $ftp_server = "ftp.example.com";
    $username = "xxxx";
    $password = "xxxxxx";

    // Connect to FTP server
    $conn_id = ftp_connect($ftp_server, 21);

    // Login with username and password
    $login_result = @ftp_login($conn_id, $username, $password);

    // Check connection
    if ((!$conn_id) || (!$login_result)) {
    echo "FTP connection has failed!";
    echo "Cannot login";
    die;
    } else {
    echo "<br>Connected to Upload File Server.<br>";
    }
    // close the FTP stream
    ftp_close($conn_id);
    ?>

    PHP version of the web server is 5.2.6
    Configure Command in PHP info does not include "enable-ftp" and I am wondering this is causing the problem.
    I cannot access to php cofiguration file on the web server (shared hosting), and the hosting company does not change any configuration for me.
    So I don't know how to add enable-ftp.

    How can I make it work?
    Your advice would be much appreciated. Thanks!

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    always turn up error reporting when developing
    PHP Code:
    ini_set('display_errors'1);
    error_reporting(E_ALL); 

  3. #3
    SitePoint Member
    Join Date
    Feb 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    and remember to turn off after development ;-)

    Seriously - because I always forget.


Tags for this Thread

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
  •