title: Downloading a 2MB File in PHP
body: <p>I'm writing a function that updates a database file every 30 days. It works great for small files, but for files over 200K or so, it just downloads a partial file. How can I make this work with files up to 2MB? </p>
  
  <pre><code>function lsmi_geoip_update() {
      $dir = dirname( __FILE__ );
      $localfilev4 = $dir . '/data/GeoIPv4.dat';
      $localfilev6 = $dir . '/data/GeoIPv6.dat';
      if ( file_exists( $localfilev4 ) ) {
          rename($dir . '/data/GeoIPv4.dat', $dir . '/data/OLD_GeoIPv4.dat');
          $newfilev4 = file_get_contents('http://gdriv.es/geoipupdate/GeoIPv4.dat');
          file_put_contents($dir . '/data/GeoIPv4.dat', $newfilev4);
          // unlink($dir . '/data/OLD_GeoIPv4.dat');
      }
      if ( file_exists( $localfilev6 ) ) {
          rename($dir . '/data/GeoIPv6.dat', $dir . '/data/OLD_GeoIPv6.dat');
          $newfilev6 = file_get_contents('http://gdriv.es/geoipupdate/GeoIPv6.dat');
          file_put_contents($dir . '/data/GeoIPv6.dat', $newfilev6);
          // unlink($dir . '/data/OLD_GeoIPv6.dat');
      }
  }
  </code></pre>
  
  <p>Here's the output:</p>
  
  <p><a href="https://i.stack.imgur.com/aKed8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aKed8.png" alt="enter image description here"></a></p>