PHP ftp_alloc() Funktion
Beispiel
Weisen Sie Speicherplatz für eine Datei zu und laden Sie die Datei auf den FTP-Server hoch:
<?php
// connect and login to FTP server
$ftp_server = "ftp.example.com";
$ftp_conn = ftp_connect($ftp_server) or die("Could not connect to $ftp_server");
$login = ftp_login($ftp_conn, $ftp_username, $ftp_userpass);
$file = "/test/myfile";
// allocate space
if (ftp_alloc($ftp_conn, filesize($file), $result))
{
echo "Space allocated on server. Sending $file.";
ftp_put($ftp_conn, "/files/myfile", $file, FTP_BINARY);
}
else
{
echo "Error! Server said: $result";
}
// close connection
ftp_close($ftp_conn);
?>
Definition und Verwendung
Die Funktion ftp_alloc() weist Platz für eine Datei zu, die auf den FTP-Server hochgeladen werden soll.
Hinweis: Viele FTP-Server unterstützen diesen Befehl nicht!
Syntax
ftp_alloc(ftp_conn, filesize, result);
Parameterwerte
Parameter | Description |
---|---|
ftp_conn | Required. Specifies the FTP connection to use |
filesize | Required. Specifies the number of bytes to allocate |
result | Optional. Specifies a variable to store the server response in |
Technische Details
Rückgabewert: | TRUE bei Erfolg, FALSE bei Misserfolg |
---|---|
PHP-Version: | 5+ |
❮ PHP-FTP-Referenz