The ftp_alloc() function allocates space for a file to be uploaded to the FTP server.
Syntax
ftp_alloc(connection,size_of_file,res);
Parameters
connection − The FTP connection to use
size_of_file − The number of bytes to allocate
res − A variable to store the server response
Return
The ftp_alloc() function returns TRUE on success or FALSE on failure
Example
The following is an example −
<?php $myFile = "demo.txt"; $con = ftp_connect('192.168.0.4'); $login_result = ftp_login($con, 'yuvgj2j', 'yuvgj2j'); if (ftp_alloc($con, filesize($myFile), $res)) { echo "Sending $file\n"; ftp_put($con, 'D:/ds', $myFile, FTP_BINARY); } else { echo "Failed in allocating space! Message = $res\n"; } ftp_close($con); ?>