FTP Function just wont work! help!

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hey all,

First up, I am a newb, so go easy on me!

I am having issues with the FTP Function ... I have read MANY posts on
similar problems, but have found no fixes that seem to work (for me at
least) ...

I have pretty much cut and paste the FTP example from PHP.net. The
code connects to and logs into the FTP server fine, but never uploads

Bellow is my form code to retrieve the source file name :


<form name='ftpUpload' method='post' action='ftp.php'>
  <input type='file' name='uploadFile'>
  <input name='Upload' type='submit' value='Upload'>


And here is the code in 'ftp.php' :


// set up basic connection

$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// check connection
if ((!$conn_id) || (!$login_result)) {
       echo "<br>FTP connection has failed!";
       echo "<br>Attempted to connect to '<b>$ftp_server</b>', as user
   } else {
       echo "<br>Connected to '<b>$ftp_server</b>', as user

// upload the file
$upload = ftp_fput($conn_id, $destination_file, $source_file,

// check upload status
if (!$upload) {
       echo "<br>FTP upload has failed!";
   } else {
       echo "<br>Uploaded '<b>$source_file</b>' to
'<b>$ftp_server</b>' as '<b>$destination_file</b>'";

// close the FTP stream


The results are the same everytime. "FTP upload has failed!"

I have tried using $ftp_fput, but this generates the error "expects
parameter 3 to be resource".

So I tried opening the $source_file using :

$myFile = $fopen($source_file, 'r');
$upload = ftp_fput($conn_id, $destination_file, $myFile, FTP_BINARY);

but this returns the same error as above, and also states that the
source file does not exist - but in the location of 'ftp.php' on the
web server!! (as though I am trying to get the source file from thw
web server, despite the fact that the $source_file is the full path
and name of the file from the local machine. eg

So what am I doing wrong? how can I get this to work? I am at a loss!

Cheers in advance,


Re: FTP Function just wont work! help!

Quoted text here. Click to load it

Not a chance!

Quoted text here. Click to load it


Quoted text here. Click to load it

Not reading the manual!

Quoted text here. Click to load it

Read The F****** Manual


Re: FTP Function just wont work! help!

'RTFM' *blush*

cheers ... worked a treat ...

Site Timeline