Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: FTP functions


Message #1 by cullan.crothers@w... on Thu, 13 Dec 2001 15:11:44
Dear P2P:

I am trying to get the PHP FTP functions to complete correctly. I am using 
PHP4, Windows 2000 Server, and IIs. I get this error in my browser window--
->>>

Connected to SERVER, for user username
Warning: ftp_put: c:\inetpub\ftproot: The filename, directory name, or 
volume label syntax is incorrect. in C:\inetpub\wwwroot/ftp.php on line 28
Ftp upload has failed!

--->>>>

I am using the following code:

<?php

// set up varibles

$ftp_server = "SERVER";
$destination_file = "c:\\inetpub\\ftproot";
$source_file = "c:\\crothers.txt";
$ftp_user_name = "username";
$ftp_password = "password";

// login with username and password

$conn_id = ftp_connect($ftp_server); 
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_password); 

// check connection

if ((!$conn_id) || (!$login_result)) { 
        echo "Ftp connection has failed!";
        echo "Attempted to connect to $ftp_server for user 
$ftp_user_name"; 
        die; 
    } else {
        echo "Connected to $ftp_server, for user $ftp_user_name";
    }

// upload the file

$upload = ftp_put($conn_id, "$destination_file", "$source_file", 
FTP_ASCII); 

// check upload status

if (!$upload) { 
        echo "Ftp upload has failed!";
    } else {
        echo "Uploaded $source_file to $ftp_server as $destination_file";
    }

// close the FTP stream 

ftp_quit($conn_id); 

?>

Is there a clue as to what I am doing wrong here? Is my file structure 
syntax correct here? The error seems to think it is not. Should this be 
changed? Any help would be greatly appreciated!

Cullan Crothers
cullan.crothers@w...


  Return to Index