ftp_alloc() function in PHP


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
";       ftp_put($con, 'D:/ds', $myFile, FTP_BINARY);    } else {       echo "Failed in allocating space! Message = $res
";    }    ftp_close($con); ?>

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019

69 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements