Ik ben er nu al een paar uur mee bezig geweest en ik heb ook nog op GoT gezocht en bij google en ik denk nu: ik vraag het wel even. Ik wil simpelweg een bestand kunnen uploaden naar een bepaalde variabele directory. Onderstaand script(standaardvoorbeeld uit Manual) zou dit op een kleine aanpassing na moeten kunnen. Het probleem is dat de regel "upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY)"niet werkt bij mij. Hij zegt dat hij het bestand niet kan vinden, terwijl ik dat met zo'n standaard input type=file textveld doe. Ik gebruik die variabele die daar uit komt als source_file. $destination_file heb ik maar gelijk gesteld aan de homedirectory van de site. Ik zou dan denken dat het goed moet gaan, maar niet dus. Wat doe ik fout?
PHP:
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
| <?php // 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"); // check connection if ((!$conn_id) || (!$login_result)) { echo "Ftp connection has failed!"; echo "Attempted to connect to $ftp_server for user $user"; die; } else { echo "Connected to $ftp_server, for user $user"; } // upload the file $upload = ftp_put($conn_id, "$destination_file", "$source_file", FTP_BINARY); // check upload status if (!$upload) { echo "Ftp upload has failed!"; } else { echo "Uploaded $source_file to $ftp_server as $destination_file"; } // close the FTP stream ftp_quit($conn_id); ?> |