FTP put uploads file with zero size
<p>I'm trying to upload a file from the local machine drive to a server.</p>

<p>I uploaded the file with the following code but it uploads the file with 0 byte size or a blank file.</p>

<p>Also, I did not get all the file path of the local file. It shows the server path. For example, if my local file is on D:/abc/abc.txt, it shows /public_html/abc.txt</p>

<p>Please help.</p>

<pre><code>&lt;?php
echo "hi";
echo "\n";

$host = '000.000.00.000';
$usr = 'userName';
$pwd = 'password';

$temp =  $_FILES["file"];
$local_file = realpath($_FILES["file"]["name"]["r"]);

$ftp_path = "/public_html/Download/".$_POST['file'];

echo "This is file to Upload :";
echo "\n";

print($local_file);

// connect to FTP server (port 21)
$conn_id = ftp_connect($host, 21) or die ("Cannot connect to host");

// send access parameters
ftp_login($conn_id, $usr, $pwd) or die("Cannot login");

// perform file upload
print ("This is ftp path : ");
print($ftp_path);
print("New line : ");

$upload = ftp_put($conn_id,  $ftp_path, $local_file , FTP_ASCII , 0);

print (!$upload) ? 'Cannot upload' : 'Upload complete';
print ("\n") ;

ftp_close($conn_id);
?&gt;
</code></pre>