title: downloading file from ftp server corrupted,
body: <p>Im have a schema when upload file to ftp server its automatic encrypted and when download file its automatic decrypt the file . when i try to run the program, upload file to ftp server its success and file was encrypted. but when download file, sometimes it cant connected to ftp server (the idm showing process  just connecting), and sometimes it success download, but the file corrupted. what i miss? 
  here i have the code :
  prosesdownload.php (this class to dekrypt the file on the ftp server)</p>
  
  <pre><code>&lt;html&gt;
  &lt;?php
  include 'ftpconfig.php';
  include 'aes.php';
  $file = $_GET['id'];
  $fileFtp = 'ftp://'.$ftp_user_name.':'.$ftp_user_pass.'@'.$ftp_server;
  $crypt = new aes_encryption();
  $fileName = str_replace('.enc','',$fileFtp.'/'.$file);
  $fileNamee = str_replace('.enc','',$file);
  $enkrip = $crypt-&gt;decrypt_file($fileFtp.'/'.$file, $fileName);
  if (!$enkrip) {
  echo "Gagal";
  }
  else {
  ?&gt;
      &lt;head&gt;
      &lt;/head&gt;
  &lt;body&gt;
  &lt;h1&gt;&lt;a href="download.php?id=&lt;?php echo $fileNamee ?&gt;"&gt;Click Here To Download File&lt;/a&gt;&lt;/h1&gt;
  &lt;?php
  } 
  ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the download.php (to get the file was decrypted)</p>
  
  <pre><code>&lt;html&gt;
  &lt;?php
  include 'ftpconfig.php';
  $file = $_GET['id'];
  $fileFtp = 'ftp://'.$ftp_user_name.':'.$ftp_user_pass.'@'.$ftp_server.'/'.$file;
  ?&gt;
      &lt;head&gt;
          &lt;script type="text/javascript"&gt;
          window.location.href = "&lt;?php echo $fileFtp?&gt;"
  
          alert('&lt;?php echo $fileFtp?&gt;');
          window.location.href='delete.php?id=&lt;?php echo $file ?&gt;'
  
          &lt;/script&gt;
      &lt;/head&gt;
  &lt;body&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>what makes the file corrupted? the ftp server (filezilla) or the decrypt code?please give me your opinion, it will help me,</p>