PHP ftp_alloc() Functie
Voorbeeld
Wijs ruimte toe aan een bestand en upload het bestand naar de FTP-server:
<?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);
?>
Definitie en gebruik
De functie ftp_alloc() wijst ruimte toe aan een bestand dat moet worden geüpload naar de FTP-server.
Let op: Veel FTP-servers ondersteunen dit commando niet!
Syntaxis
ftp_alloc(ftp_conn, filesize, result);
Parameterwaarden
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
Winstwaarde: | WAAR bij succes, ONWAAR bij mislukking |
---|---|
PHP-versie: | 5+ |
❮ PHP FTP-referentie