DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Location
    Romeoville, IL
    Posts
    4

    Problem with accessing a FTP site with a PHP script

    Hello,

    I created this PHP script (actually it came from my textbook). It apparently connects to the FTP site okay, but I cannot log on. The user name and password have been double-checked for typos, but for security reasons I cannot put them up here, so I just put "host.com", "user_name" and "password" here.

    PHP Code:

    <html> 
    <head> 
      <title>LSR FTP Script</title> 
    </head> 
    <body> 
    <h1>LSR FTP Script</h1>  
    <?php 
    // set up variables 
    $host 'host.com'
    $user 'user_name'
    $password 'password'
    $remotefile 'addendums.txt.gz'
    $localfile 'addendums.txt.gz'

    // connect to host 
    $conn ftp_connect("$host");  
    if (!
    $conn

      echo 
    'Error: Could not connect to ftp server<br />'
      exit; 

    echo 
    "Connected to $host.<br />"

    // log in to host 
    $result ftp_login($conn$user$pass); 
    if (!
    $result

      echo 
    "Error: Could not log on as $user<br />"
      
    ftp_quit($conn); 
      exit; 

    echo 
    "Logged in as $user<br />"

    echo 
    'Getting file from server...<br />'
    $fp fopen ($localfile'w'); 
    if (!
    $success ftp_fget($conn$fp$remotefileFTP_BINARY)) 

      echo 
    'Error: Could not download file';  
      
    ftp_quit($conn); 
      exit; 

    fclose($fp); 
    echo 
    'File downloaded successfully'

    // close connection to host 
    ftp_quit($conn); 

    ?> 
    </body> 
    </html>
    Is there anything I can add to this script that will allow me to see exactly why the user name is not being accepted?

    Also, if I use my browser to FTP to the FTP site, I CAN enter my user name and password, and can get into the FTP site fine.

    The messages I receive when I attempt to connect to the FTP site using my PHP script are as follows:

    -----
    Connected to idx.fnismls.com..
    Error: Could not log on as user_name
    -----

    Thanks in advance!

    Miaow

  2. #2
    Join Date
    Mar 2005
    Location
    UK, London
    Posts
    150
    Does the ftp server use encrypted passwords?

  3. #3
    Join Date
    Jul 2005
    Location
    Romeoville, IL
    Posts
    4
    No, it doesn't.

Similar Threads

  1. Problem accessing SQL server from ASP
    By Thomas in forum ASP.NET
    Replies: 6
    Last Post: 11-10-2009, 02:31 PM
  2. Replies: 1
    Last Post: 10-20-2002, 12:25 PM
  3. Replies: 1
    Last Post: 04-22-2002, 01:30 PM
  4. Problem accessing the Active Directory
    By Melquisedeque in forum ASP.NET
    Replies: 0
    Last Post: 02-07-2002, 07:21 AM
  5. Replies: 0
    Last Post: 02-07-2001, 10:05 AM

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
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links