I am trying to utilize the ftp function on php.net website but I get this error when i use it:
Fatal error: Call to undefined function: ftp_connect() in /home/.gainsborough/tomcat/domaingoeshere.com/distributors/upload.php on line 7
I read on the php.net message board that it has problems working behind a nat box and a firewall but havent yet been able to try it on a system infront of a firewall. If it would only work infront of a firewall it would be rather useless to me anyway.
Anyway Here is the code for the input form:
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="userfile"><p>
<input type="submit" value="Upload File">
</form>
Here is the code for the php script:
<?php
$filename = "testman";
$ftp_server = "$ftpserver";
// set up basic connection
$conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server");
// 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 "Attempted to connect to $ftp_server for user $ftp_user_name";
exit;
} else {
echo "Connected to $ftp_server, for user $username";
}
// upload the file
$upload = ftp_put($conn_id, $filename, $_FILES['userfile']['tmp_name'], FTP_BINARY);
// 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_close($conn_id);
echo "upload completed! If you are not redirected automatically <a href=postclass.php?image1test=PASS><b>click here</b></a><br>$userfile <br>$name<br>$size<br>$userfile";
?>