PHP & FTP

Uit De Vliegende Brigade
Versie door Jeroen Strompf (overleg | bijdragen) op 29 dec 2016 om 22:30
(wijz) ← Oudere versie | Huidige versie (wijz) | Nieuwere versie → (wijz)
Naar navigatie springen Naar zoeken springen

Hoe verstuur je bestanden in PHP via FTP? De belangrijkste opties:

  • Mbv. de file module - Voor recht-toe-recht-aan-toepassingen
  • Mbv. de FTP module - Voor mysterieuze en complexe situaties.

Voorbeeld

<?php

$host = "example.com";
$port = 21;
$user="jip";
$password="**********";

$connection = ftp_connect($host);
$login = ftp_login($connection, $user, $password);
ftp_pasv($connection, true); // Cruciaal!

echo "ftp_connection: $connection \n";
echo "ftp_login: $login \n";

$directory = ftp_nlist($connection,".");
var_dump($directory);

ftp_put($connection, "test-03.xml", "test-03.xml", FTP_ASCII)

?>

Bronnen