[PHP] Downloaden & Uploaden m.b.v. FTP

Pagina: 1
Acties:

Onderwerpen


Acties:
  • 0 Henk 'm!

  • Ad Hox
  • Registratie: Maart 2003
  • Laatst online: 19:58
Ik heb de volgende code in PHP:

code:
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
61
62
63
64
65
66
67
// FTP account aanmaken
// file defineren
$remote_file = 'BPFTP Server/Users.ini';
$handle = fopen('Users.ini', 'a+');

// FTP gegevens
$ftp_user_name = '*****';
$ftp_user_pass = '****';
$ftp_server = '*******.*****.net';

// verbinding maken met de FTP server
$conn_id = ftp_connect($ftp_server);

// login with username and password
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// make dir
ftp_mkdir($conn_id, $gebruikersnaam);
// try to download $file
if (ftp_fget($conn_id, $handle, $remote_file, FTP_ASCII)) {
 echo "<font color=red><BR><LI>Download Succes (to Tommey.NL)\n";
} else {
 echo "<font color=red><BR><LI>There was a problem with downloading\n";
}

// schrijven
$dir = 'D:/sambar61/docs/';
$content = '
[$gebruikersnaam] 
Login=$gebruikersnaam 
Pass=$wachtwoord 
Home-Ip=-= All IP Homes =- 
RelativePath=1 
TimeOut=600 
MaxConPerIp=1 
MaxUsers=0 
RatioMethod=0 
RatioUp=1 
RatioDown=1 
RatioCredit=0 
MaxSpeedRcv=512 
MaxSpeedSnd=512 
QuotaCurrent=0 
QuotaMax=5000000 
Dir0=$dir\$gebruikersnaam
Attr0=RWDAMLSK 
Info_Email=$email 
Info_Notes=ip adres: $REMOTE_ADDR 
Stat_Login=2 
Stat_LastLogin= 
Stat_LastIP= 
Stat_KBUp=0 
Stat_KBDown=0 
Stat_FilesUp=0 
Stat_FilesDown=0 
Stat_FailedUp=0 
Stat_FailedDown=0 
';
fwrite($handle, $content);

// uploaden
ftp_fput($conn_id, $remote_file, $handle, FTP_ASCII);


// close the connection and the file handler
ftp_close($conn_id);
fclose($handle);


Nu krijg ik de volgende melding:
  • There was a problem with downloading
  • Warning: ftp_fput (): CANNOT STOR. No permission in register.php on line 404
Lijn 404: ftp_fput($conn_id, $remote_file, $handle, FTP_ASCII);

Wat ik heb gedaan:
  • Users.ini met CHMOD op 777
  • BPFTP Server/Users.ini staat niet meer op 'Alleen-lezen' (dat bestand staat op D:/, dan is ie toch wel gewoon writeable?
Hij mag (volgens mij) in geeneen bestand schrijven volgens mijn FTP webserver logs. Hoe los ik dit op?

code:
1
2
3
4
5
6
7
8
9
10
11
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > RETR BPFTP Server/Users.ini
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > asked to download 'D:\sambar61\docs\BPFTP Server\Users.ini' --> Access denied.
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > 550 Cannot RETR. No permission.
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > PORT 81,173,33,6,225,206
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > 200 Port command successful.
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > STOR BPFTP Server/Users.ini
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > asked to upload 'BPFTP Server\Users.ini' in 'D:\sambar61\docs\' --> Access denied.
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > 550 Cannot STOR. No permission.
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > QUIT 
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > 221 Bye bye ...
(000003) 30-3-2005 16:42:50 - admin (81.173.33.6) > disconnected. (00:00:00)


Vraag: EDIT: Hij schrijft dus wel in Users.ini, maar wat ie niet doet, zijn de variabelen invullen in dat bestand (terwijl bij MKDIR dat wel lukt, en daarvoor :S?)! Dus het gaat om het bestand wat op een HDD staat, hoe krijg ik die writeable, en die variabelen invullen?

[ Voor 15% gewijzigd door Ad Hox op 30-03-2005 16:58 ]


Acties:
  • 0 Henk 'm!

  • knopper
  • Registratie: September 2001
  • Laatst online: 07-09 23:05

knopper

Sander Knopper

Moet je sowieso niet deze functie gebruiken voordat je wat gaat uploaden: http://nl2.php.net/manual/en/function.ftp-alloc.php

Acties:
  • 0 Henk 'm!

  • djluc
  • Registratie: Oktober 2002
  • Laatst online: 21-09 14:28
Werkt het voorbeeldje van http://www.php.net/ftp wel? Dan weet je in elk geval of het aan je script of ergens anders aan ligt.

Acties:
  • 0 Henk 'm!

Verwijderd

Dit is een probleem met je FTP server, niet met je PHP scriptje, zo te zien.
Warning: ftp_fput (): CANNOT STOR. No permission in register.php on line 404
Je hebt een 404 error. :P