I need to have a page that will allow uploading of an image. Please help:
<?php
$fp = ftp_connect("ftp://ftp." . $domain);
$login = ftp_login($fp, $userid, $login_password);
$copy = ftp_fput($fp, "/directory/".$file, $file, FTP_BINARY);
$exit = ftp_quit($fp);
if ( $fp && $login && $copy && $exit ) {
// bunch of commands if it works
}
else {
// bunch of commands if it fails
}
?>
The $domain variable is, of course, the domain name (domain.com), and I have conatenated it with the protocol and prefix "ftp://ftp.". For a test I just coded in echo $fp;, to make sure it worked, and, sure enough, it returned "1", so it's connecting without a problem. It also exits nicely ($exit).
The $file var. is a "file" input type parsed from a form.
However, I the following error message for the $login and the $copy variables:
Warning: Unable to find ftpbuf 0 in .../www.domain.com/file.php on line 64
Warning: Unable to find ftpbuf 0 in .../www.domain.com/file.php on line 65
Of course, I've changed the real domain and dirs to domain.com, just for the purpose of example and security.