ftp upload by php?

Posts 1–4 of 4 · Page 1 of 1
ftp upload by php?
this is my code to upload files to another server.
but it doesn't work, why?
if i fill in the right things it doesn't work



[PHP]<form name="form1" enctype="multipart/form-data" method="post" action="<?php $PHP_SELF ?>">
<input type="file" name="source_file">
<br>
<input type="submit" name="submit" value="Submit">
</form><br />
<?php
error_reporting(E_ALL);
if(isset($_POST['submit'])) {
$size = $_FILES['source_file']['size'] / 1024 / 1024;
$size = round($size, 2);
echo 'Het volgende bestand wordt geüpload:<br />
Naam: ' . $_FILES['source_file']['name'] .
'<br />Grootte: ' . $size .
' MB<br /><b>tmp_name:</b> ' . $_FILES['source_file']['tmp_name'] . '<br />
de upload wordt verwerkt...<br />';
//variabelen definiëren
$ftp_server = "ftp.teun95.sixserve.com";
$ftp_user_name = "admin@teun95.sixserve.com";
$ftp_user_pass = "hoedje11";
$source_file = $_FILES['source_file']['tmp_name'];
$destination_file = $_FILES['source_file']['name'];

// maak een basis connectie aan
$conn_id = ftp_connect($ftp_server);
ftp_pasv($conn_id,TRUE);

// meldt je aan met een gebruikersnaam en wachtwoord
$login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);

// controleer de verbinding
if ((!$conn_id) || (!$login_result)) {
echo "FTP connectie is mislukt!<br />";
echo "Probeerde naar $ftp_server te verbinden met de gebruiker $ftp_user_name<br />";
exit;
} else {
echo "Verbonden met $ftp_server, als gebruiker $ftp_user_name<br />";
}

// upload een bestand
$upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);

// controleer de upload status
if (!$upload) {
echo "FTP upload is mislukt!<br />";
} else {
echo "Geupload: $source_file naar $ftp_server als $destination_file<br />";
}

// sluit de FTP stream
ftp_close($conn_id);

if($conn_id == "1" && $login_result == "1" && $upload == "1") echo '<br><b>Operatie succesvol</b><br /><br />';
else echo '<b>Mislukt!</b><br /><br />';
}
?>
[/PHP]
looks ok, but hey im just a beginner coder =-/
I don't know about MPGH Coding like colours and stuff and I don't know PHP That well but what is the red stuff?
English:
Do you get any errors?

Dutch(Dutch in code, so dutch support):
Krijg je meldingen of errors?

[php]
<?php
if($conn_id == "1" && $login_result == "1" && $upload == "1")
?>
[/php]

English:
No integers in quotes!

Dutch(Dutch in code, so dutch support):
Een integer (getal) hoort niet tussen quotes te staan!

[php]
<?php
echo "Geupload: $source_file naar $ftp_server als $destination_file<br />";
?>
[/php]

English:
Variables the same!

Dutch(Dutch in code, so dutch support):
Een variabel mag er ook niet instaan!

Howto?
[php]
<?php
if($conn_id == 1 && $login_result == 1 && $upload == 1)
# ----------------------------------
echo "Geupload: ".$source_file." naar ".$ftp_server." als ".$destination_file."<br />";
?>
[/php]
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us