title: CMD Prompt > FTP Size Command
body: <p>I'm developing a PHP App on IIS 7.5, which uses PHP FTP commands.</p>
  
  <p>These all work, apart from <code>ftp_size()</code>.</p>
  
  <p>I've tested:</p>
  
  <p><code>cmd.exe &gt; ftp host &gt; username &gt; password &gt; SIZE filename = Invalid Command</code></p>
  
  <p>However, if I access the FTP site through an Internet Browser, the filesize is displayed.</p>
  
  <p>Do I need to install FTP Extensions, and if so, which ones and where do I get them?</p>
  
  <p>Here is the PHP Code:</p>
  
  <pre><code>&lt;?php
  // FTP Credentials
  $ftpServer = "www.domain.com";
  $ftpUser = "username";
  $ftpPass = "password";
  
  // Unlimited Time
  set_time_limit(0);
  
  // Connect to FTP Server
  $conn = @ftp_connect($ftpServer)
  or die("Couldn't connect to FTP server");
  
  // Login to FTP Site
  $login = @ftp_login($conn, $ftpUser, $ftpPass)
  or die("Login credentials were rejected");
  
  // Set FTP Passive Mode = True
  ftp_pasv ($conn, true);
  
  // Build the file list
  $ftp_nlist = ftp_nlist($conn, ".");
  
  // Alphabetical sorting
  sort($ftp_nlist);
  
  // Display Output
  foreach ($ftp_nlist as $raw_file) {
      // Get the last modified time
      $mod = ftp_mdtm($conn, $raw_file);
      // Get the file size
      $size = ftp_size($conn, $raw_file);
      // Size is not '-1' =&gt; file
        if (!(ftp_size($conn, $raw_file) == -1)) {
          //output as file
          echo "Filename: $raw_file&lt;br /&gt;";
          echo "FileSize: ".number_format($size, '')."Kb&lt;/br&gt;";
          echo "Last Modified: ".date("d/m/Y H:i", $mod)."&lt;/br&gt;";
        }
  }
  ?&gt;
  </code></pre>