PHP ftp_alloc()関数
例
ファイル用のスペースを割り当て、ファイルをFTPサーバーにアップロードします。
<?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);
?>
定義と使用法
ftp_alloc()関数は、FTPサーバーにアップロードされるファイル用のスペースを割り当てます。
注:多くのFTPサーバーはこのコマンドをサポートしていません!
構文
ftp_alloc(ftp_conn, filesize, result);
パラメータ値
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 |
技術的な詳細
戻り値: | 成功した場合はTRUE、失敗した場合はFALSE |
---|---|
PHPバージョン: | 5歳以上 |
❮PHPFTPリファレンス