Webprogramozás arr PHP info ftp kapcsolodás hiba
(#1) d22rpi 2011.05.19. 16:12

d22rpi
d22rpi
Kezdő

Sziasztok!

egy php scriptel lenne problémám ugyanis nem tud csatlakozni ftp re, amugy egy fájlt fog megjeleniteni egy weboldalon.
itt a hiba:
Warning: ftp_pasv() expects parameter 1 to be resource, boolean given in /mnt/ultraweb/d/di/dir/log/console.php on line 28
FTP connection has failed!

a 28 as vonal az ez: ftp_pasv($conn_id, true);

itt a kód:

$ftp_server = 'localhost';
$ftp_user_name = 'user';
$ftp_user_pass = 'pw';
$ftp_directory = '/tf';

$allow_clear = 0;
$filename = 'script filename';

$txt_filename = 'consolelog.txt';

// 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);

ftp_pasv($conn_id, true);

// check connection
if ((!$conn_id) || (!$login_result)) {
die("<code>FTP connection has failed!</code>");
}

if (!ftp_chdir($conn_id, $ftp_directory)) {
die("<code>Couldn't change directory to ".$ftp_directory.".</code>");
}

if($_GET['clear'] && $allow_clear) {
if(!$file = fopen($txt_filename, 'w')) {
die("<code>Couldn't open ".$txt_filename."!");
}
if(!fwrite($file, ' ')) {
die("<code>Couldn't write to ".$txt_filename."!");
}
fclose($file);

if (!ftp_put($conn_id, "console.log", $txt_filename, FTP_ASCII)) {
die("<code>Couldn't upload blank file to console.log.</code>");
}

header("location: ".$filename);
exit(0);
}

if (!ftp_get($conn_id, $txt_filename, $ftp_directory."/console.log", FTP_ASCII)) {
die("<code>Couldn't get console log from server.</code>");
}

if(!$file = fopen($txt_filename, 'r')) {
die("<code>Couldn't open ".$txt_filename."!");
}
$text = fread($file, filesize($txt_filename));
fclose($file);

// close the connection
ftp_close($conn_id);