hi,
i trying to write a basic ftp script that enables a user to select a file on their local machine which then when a form is submitted. it ftp's the file to a directory
code i have so far is:
<?php
if(!isset($address)){
print"<form name=\"frm\" method=\"post\" action=\"ftp1.php\">";
print"Firstly put required dump file into <b>docs</b> folder.<br>";
print"Enter name of file (e.g. <b>Caladan</b>.txt)<br><br>";
print"Address of File: <input type=\"file\" name=\"address\"><br>";
print"<br><br><input type=\"submit\" value=\"Add Txt Dump File\">";
print"</form>";
}else{
$ftp_server="ftp://some.server.co.uk";
$ftp_user_name="someuser";
$ftp_user_pass="somepassword";
$source_file = $address;
$destination_file = $source_file;
// 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 "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 $ftp_user_name";
}
// upload the file
$upload = ftp_put($conn_id, $destination_file, $source_file, 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);
}
?>
But when i submit the local file, i get the following errors:
Warning: Unable to find ftpbuf 0 in /home/***/docs/ftp.php on line 29
FTP connection has failed!Attempted to connect to [url]ftp://some.server.co.uk[/url] for user someuser
anybody got any ideas where im going wrong, or could suggest a better way of doing this???
can't find much information on ftpbuf?
Thanks