
shidori
Kezdő
|
Hmm. Ja ebben van valami, nem vagyok még sajnos mesteri szinten a php-ban =/
shidori.dyndns.org||okhost.eu||asdexed.dyndns.org
|

RimElek
VIP
|
Mondjuk a hiba az első paraméterrel van, nem a másodikkal :) És mivel az első paraméternek erőforrásnak kell lennie, de boolean ( valószínű hamis, ami csatlakozási hibát jelent ) így az ftp_pasv kitörlése sem segítenhe. Mert attól még nem kapcsolódik, hogy nem lesz passzív módba kapcsolva a kapcsolat. Ami egyébként tényleg booleant vár második paraméterben. Tehát jó az a boolean, csak a @ -ok használatát kéne mérsékelni ( vagy legalább if-el vizsgálni is_resource() -el. ), amitől az sem derül ki, hogy hiba történt. Csak később. Pl saját gépen menne a program, ahol nincs is ftp szerver. Vagy más tárhelyen, ahol meg nem localhost az ftp szerver neve.
Utoljára szerkesztette: RimElek 2011.05.20. 20:36
|

shidori
Kezdő
|
üdv!
ha localhoston van az ftp szerver akkor kikell kommentezni az ftp_pasv-ot. itt a kod esetleg ha kell:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
$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);
|
de ha nem localhoston van akkor probald ezt:
1
2
3
4
5
|
ftp_pasv($conn_id, 1);
|
a true helyett irj "1"-et
remélem tudtam segiteni! sok sikert!
shidori.dyndns.org||okhost.eu||asdexed.dyndns.org
|

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