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+ |
❮ PHP FTP 참조