Can't upload file with PHP ftp

studio-dk

New member
Joined
Mar 16, 2015
Messages
1
Hello,

I have wrote a script to upload a file. But if I run it the image is corrupted on the server. But if I try an ftp server without DirectAdmin it works fine.

The problem is only with ftp servers of DirectAdmin.

This is my script:
PHP:
class ftp {

	private $conn;
	public $debug = false;

	public function __construct($server) {
		$this->conn = ftp_connect($server);
	}

	public function login($uname, $pwd) {
		ftp_login($this->conn, $uname, $pwd);
	}

	public function logout() {
		ftp_close($this->conn);
	}

	public function upload($remote_file, $file) {
		if(ftp_put($this->conn, $remote_file, $file, FTP_BINARY)) {
			if ($this->debug) echo "Upload succes {$remote_file} <br>";
		} else {
			echo "Upload fail please try again. Or contact the webmaster.";
		}
	}
}

-Daan
 
Back
Top