Hàm ftp_alloc () trong PHP
Thí dụ
Phân bổ không gian cho tệp và tải tệp lên máy chủ 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);
?>
Định nghĩa và Cách sử dụng
Hàm ftp_alloc () phân bổ không gian cho tệp được tải lên máy chủ FTP.
Lưu ý: Nhiều máy chủ FTP không hỗ trợ lệnh này!
Cú pháp
ftp_alloc(ftp_conn, filesize, result);
Giá trị tham số
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 |
Chi tiết kỹ thuật
Giá trị trả lại: | ĐÚNG về thành công, SAI về thất bại |
---|---|
Phiên bản PHP: | 5+ |
❮ Tham chiếu FTP PHP