PHP FTP server probleem
Ik heb het volgende probleem:
Mijn FTP server werkt niet, zo dit aan de php scripts kunnen liggen ?
Dit zijn mijn instellingen van de scripts:
index.php
Code (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Compucolor upload</title>
<style type="text/css">
html, body {
font-family: verdana;
font-size: 11px;
}
h1 {
font-family: verdana;
font-size: 15px;
border-bottom: 1px solid black;
margin-bottom: 10px;
}
#main {
width: 500px;
background-color: #cccccc;
padding: 10px;
margin: 30px auto;
}
#uploaders {
padding: 5px;
background-color: white;
}
#uploaders div {
margin: 5px 2px 2px 2px;
padding: 3px;
}
.wit {
background-color: white;
margin: 5px 0;
padding: 5px;
}
a {
color: black;
cursor: pointer;
text-decoration: underline;
}
</style>
<script type="text/javascript">
var c=1,d=document;
function addUploader(){
c++; // haha.. c++ .. muhahha
var di = document.createElement('div');
di.innerHTML = "<input type='file' name='bestand"+c+"' />";
document.getElementById('uploaders').appendChild( di );
}
function deSubmit(){
var s=d.getElementById('submitter');
s.disabled="true";
s.value="Een moment geduld, uw bestanden worden geupload!";
}
</script>
</head>
<body>
<div id="main">
<h1>CompuColor file upload</h1>
<div class="wit" style="color: red;">
</div>
<div class="wit" style="color: green;">
De volgende bestanden zijn succesvol geupload:<br />
<ul>
<li></li>
</ul>
</div>
<form method="post" enctype="multipart/form-data">
<div id="uploaders">
[<a onclick="addUploader();">Meer bestanden toevoegen</a>]<br /><br />
Selecteer de bestanden welke u opsturen wilt:<br />
<div class="uploader">
<input type="file" name="bestand1" />
</div>
</div>
<div class="wit">
<input type="submit" id="submitter" onclick="deSubmit();" value="Bestanden uploaden" />
</div>
</form>
</body>
</html>
?>
index2.php
Lijkt me sterk dat PHP dit kan veroorzaken.
Volgens iemand op mijn werk, ligt het aan de bestandsrechten ?
Ook krijg ik bij ftp.compucolor.nl niks te zien.
Het klopt dat ik niet kan inloggen in mijn ftp server.
index2.php
Code (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Compucolor upload</title>
<style type="text/css">
html, body {
font-family: verdana;
font-size: 11px;
}
h1 {
font-family: verdana;
font-size: 15px;
border-bottom: 1px solid black;
margin-bottom: 10px;
}
#main {
width: 500px;
background-color: #cccccc;
padding: 10px;
margin: 30px auto;
}
#uploaders {
padding: 5px;
background-color: white;
}
#uploaders div {
margin: 5px 2px 2px 2px;
padding: 3px;
}
.wit {
background-color: white;
margin: 5px 0;
padding: 5px;
}
a {
color: black;
cursor: pointer;
text-decoration: underline;
}
</style>
<script type="text/javascript">
var c=1,d=document;
function addUploader(){
c++; // haha.. c++ .. muhahha
var di = document.createElement('div');
di.innerHTML = "<input type='file' name='bestand"+c+"' />";
document.getElementById('uploaders').appendChild( di );
}
function deSubmit(){
var s=d.getElementById('submitter');
s.disabled="true";
s.value="Een moment geduld, uw bestanden worden geupload!";
}
</script>
</head>
<body>
<div id="main">
<h1>CompuColor file upload</h1>
<div class="wit" style="color: red;">
</div>
<div class="wit" style="color: green;">
De volgende bestanden zijn succesvol geupload:<br />
<ul>
<li></li>
</ul>
</div>
<form method="post" enctype="multipart/form-data">
<div id="uploaders">
[<a onclick="addUploader();">Meer bestanden toevoegen</a>]<br /><br />
Selecteer de bestanden welke u opsturen wilt:<br />
<div class="uploader">
<input type="file" name="bestand1" />
</div>
</div>
<div class="wit">
<input type="submit" id="submitter" onclick="deSubmit();" value="Bestanden uploaden" />
</div>
</form>
</body>
</html>
?>
Code (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
if($_SERVER['REQUEST_METHOD'] == "POST"){
$target_path = "Upload/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
/*
// Open FTP connection
$ftp_server = "ftp.compucolor.nl"; //address of ftp server (GEEN ftp://)
$ftp_user_name = "compucolor"; // Username
$ftp_user_pass = "digitaal"; // Password
$conn = ftp_connect($ftp_server);
// check the connection
if($conn ==FALSE){
$error = "Kon niet met de FTP server verbinden";
include("uploader.template.php");
die();
}
// Login with username and password
$login_result = ftp_login($conn, $ftp_user_name, $ftp_user_pass);
// Check the logon
if($login_result==FALSE){
$error = "Kon niet op de FTP server inloggen";
include("uploader.template.php");
die();
}
$upld = array();
// make the upload
foreach($_FILES as $file){
if($file['error'] == 0){
//$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_ASCII);
$st = ftp_put($conn, "Upload/".$file['name'], $file['tmp_name'], FTP_BINARY);
if($st == false){
$error = "Het bestand: ".$file['name']." kon niet worden geupload!";
include("uploader.template.php");
die();
}
$upld[] = $file['name'];
}
}
// Close the FTP connection
ftp_close($conn);
*/
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Compucolor upload</title>
<style type="text/css">
html, body {
font-family: verdana;
font-size: 11px;
}
h1 {
font-family: verdana;
font-size: 15px;
border-bottom: 1px solid black;
margin-bottom: 10px;
}
#main {
width: 500px;
background-color: #cccccc;
padding: 10px;
margin: 30px auto;
}
#uploaders {
padding: 5px;
background-color: white;
}
#uploaders div {
margin: 5px 2px 2px 2px;
padding: 3px;
}
.wit {
background-color: white;
margin: 5px 0;
padding: 5px;
}
a {
color: black;
cursor: pointer;
text-decoration: underline;
}
</style>
<script type="text/javascript">
var c=1,d=document;
function addUploader(){
c++; // haha.. c++ .. muhahha
var di = document.createElement('div');
di.innerHTML = "<input type='file' name='bestand"+c+"' />";
document.getElementById('uploaders').appendChild( di );
}
function deSubmit(){
var s=d.getElementById('submitter');
s.disabled="true";
s.value="Een moment geduld, uw bestanden worden geupload!";
}
</script>
</head>
<body>
<div id="main">
<h1>CompuColor file upload</h1>
<div class="wit" style="color: red;">
</div>
<div class="wit" style="color: green;">
De volgende bestanden zijn succesvol geupload:<br />
<ul>
<li></li>
</ul>
</div>
<form method="post" enctype="multipart/form-data">
<div id="uploaders">
[<a onclick="addUploader();">Meer bestanden toevoegen</a>]<br /><br />
Selecteer de bestanden welke u opsturen wilt:<br />
<div class="uploader">
<input type="file" name="bestand1" />
</div>
</div>
<div class="wit">
<input type="submit" id="submitter" onclick="deSubmit();" value="Bestanden uploaden" />
</div>
</form>
</body>
</html>
?>
-> FTP = Programma waarmee je bestanden op je server kan zetten.
dit zou niet aan je code liggen.
Wat krijg je te zien als je probeerd in te loggen op je FTP server?
Kan je wel handmatig files upoaden? (Via DirectAdmin ofzo)
Geeft je FTP programma geen melding van wat er mis gaat? Zo niet, welk programma gebruik je exact?
PS. Plaats nooit hele scripts, alleen relevante code. (Wat nu niet van toepassing is eigenlijk, er is geen relevante code.) :)