php code to connect to remote ftp server

Posted on 2012-09-07
Last Modified: 2012-09-08
i am looking for php code to connect to a remote ftp server

the information I have is
portnumber (21)
Question by:rgb192
    LVL 7

    Accepted Solution

    You have all information on PHP official manual.
    Here is a quick code:
    //Connect to the FTP server
    $ftpstream = @ftp_connect('localhost');
    //Login to the FTP server
    $login = @ftp_login($ftpstream, 'user', 'secret');
    if($login) {
    	//We are now connected to FTP server.
    //Close FTP connection

    Open in new window

    LVL 82

    Assisted Solution

    by:Dave Baldwin
    @itinmind, when you are first testing code, you should not use '@' in front of the functions to suppress errors.  You need to see the errors to know what is wrong so you can fix it.

    Here's another page with an example:  You might want to turn all error reporting on:  

    // Report all PHP errors (see changelog)

    Open in new window


    Author Closing Comment

    good idea to show errors


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    The viewer will learn how to count occurrences of each item in an array.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now