Hoi,
Ik wil graag een bestandje van mijn harde schijf via een ftp-connectie uploaden. Ik gebruik daarvoor de volgende code:
form.html
<html>
<head>
<title>Form</title>
</head>
<body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4 bgcolor=white vlink="#0000ff" link="#0000ff">
<form name="Attachments" method=POST action="sendimage.php" enctype="multipart/form-data">
<input type=file name=source_file size=20> <br>
<input type=submit name=btnSubmit value=Submit size=20 style="border: 1px solid #0000FF"></form>
</body>
</html>
En sendimage.php ziet er als volgt uit:
Hij maakt op de juiste manier een verbinding met de ftp-server. Alleen krijg ik de volgende foutmelding:
Connected to *********, for user ********
test2.jpg
Warning: ftp_put(): open_basedir restriction in effect. File(/tmp/phpKl2Q8N) is not within the allowed path(s): (/domains/**********/) in /domains/*********/public_html/www/sendimage.php on line 34
FTP upload has failed!
Wat doe ik nu verkeerd? Het zal wel een fout zijn in de pad-verwijzing, maar ik heb al veel combinaties geprobeerd maar ik krijg het maar niet voor elkaar.
Iemand suggesties?
Groeten,
GeniusGeri
Ik wil graag een bestandje van mijn harde schijf via een ftp-connectie uploaden. Ik gebruik daarvoor de volgende code:
form.html
<html>
<head>
<title>Form</title>
</head>
<body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4 bgcolor=white vlink="#0000ff" link="#0000ff">
<form name="Attachments" method=POST action="sendimage.php" enctype="multipart/form-data">
<input type=file name=source_file size=20> <br>
<input type=submit name=btnSubmit value=Submit size=20 style="border: 1px solid #0000FF"></form>
</body>
</html>
En sendimage.php ziet er als volgt uit:
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
| <?php $ftp_server='**************'; $conn_id = ftp_connect($ftp_server); $user="***********"; $passwd="************"; $login_result = ftp_login($conn_id, $user, $passwd); if ((!$conn_id) || (!$login_result)) { echo "FTP connection has failed!"; echo "Attempted to connect to $ftp_server for user $ftp_user_name"; die; } else { echo "<br>Connected to $ftp_server, for user $user<br>"; } ftp_chdir($conn_id, "/public_html/www/mp3/images/"); $destination_file="test2.jpg"; echo ("<br>"); //echo "<pre>"; //print_r($_FILES); //echo "</pre>"; $upload = ftp_put($conn_id, $destination_file, $_FILES['source_file']['tmp_name'], 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_close($conn_id); ?> |
Hij maakt op de juiste manier een verbinding met de ftp-server. Alleen krijg ik de volgende foutmelding:
Connected to *********, for user ********
test2.jpg
Warning: ftp_put(): open_basedir restriction in effect. File(/tmp/phpKl2Q8N) is not within the allowed path(s): (/domains/**********/) in /domains/*********/public_html/www/sendimage.php on line 34
FTP upload has failed!
Wat doe ik nu verkeerd? Het zal wel een fout zijn in de pad-verwijzing, maar ik heb al veel combinaties geprobeerd maar ik krijg het maar niet voor elkaar.
Iemand suggesties?
Groeten,
GeniusGeri
[ Voor 24% gewijzigd door GeniusGeri op 06-02-2004 12:14 ]