Latest web development tutorials

PHP ftp_alloc () function

PHP FTP Reference Complete PHP FTP Reference

Definition and Usage

ftp_alloc () function to upload files to FTP server to allocate space.

If successful, the function returns TRUE. If it fails, it returns FALSE.

grammar

ftp_alloc(ftp_connection,size,return)

参数 描述
ftp_connection 必需。规定要使用的 FTP 连接。
size 必需。规定要分配的字节数。
return 可选。规定存储服务器响应的变量。


Tips and Notes

NOTE: Many FTP servers do not support this command.


Example 1

<?php
$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");

ftp_alloc($conn,"160",$response);
echo $response;

ftp_close($conn);
?>


Example 2

<?php
$file = "myfile.txt";

$conn = ftp_connect("ftp.testftp.com") or die("Could not connect");
ftp_login($conn,"admin","ert456");

if (ftp_alloc($conn, filesize($file), $response))
{
echo "Space allocated on server.";
}
else
{
echo "Unable to allocate space. " . $response;
}

ftp_close($conn);
?>


PHP FTP Reference Complete PHP FTP Reference