A customer of mine made the decision to maneuver the web site from the somewhat nice server to some... allows refer to it as lesser nice server.

The issue is, there is a file with 40MBs to become downloaded and also the memory limit around the server is 32. To really make it even more complicated for me personally, they do not allow fopen...

Also, basically lessen the quality to 20MB it really works fine.

So, my real question is, so what can i actually do - besides lowering the quality - to make this happen?

Thanks

EDIT:`

        $fsize = filesize($file_path);
        $path_parts = pathinfo($file_path);
        $ext = strtolower($path_parts["extension"]);


        switch ($ext) {
            case "pdf": $ctype = "application/pdf";
                break;
            case "exe": $ctype = "application/octet-stream";
                break;
            case "zip": $ctype = "application/zip";
                break;
            case "doc": $ctype = "application/msword";
                break;
            case "xls": $ctype = "application/vnd.ms-excel";
                break;
            case "ppt": $ctype = "application/vnd.ms-powerpoint";
                break;
            case "gif": $ctype = "image/gif";
                break;
            case "png": $ctype = "image/png";
                break;
            case "jpeg":
            case "jpg": $ctype = "image/jpg";
                break;
            default: $ctype = "application/force-download";
        }

        header("Pragma: public"); // required
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false); // required for certain browsers
        header("Content-Type: $ctype");
        header("Content-Disposition: attachment; filename=\"" . basename($file_path) . "\";");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . $fsize);
        ob_clean();
        flush();
        readfile($file_path);`

The code i saw on php.internet

// If it's a large file, readfile might not be able to do it in one go, so:
$chunksize = 1 * (1024 * 1024); // how many bytes per chunk
if ($size > $chunksize) {
  $handle = fopen($realpath, 'rb');
  $buffer = '';
  while (!feof($handle)) {
    $buffer = fread($handle, $chunksize);
    echo $buffer;
    ob_flush();
    flush();
  }
  fclose($handle);
} else {
  readfile($realpath);
}

Use readfile() rather. It'll stream the file in small portions and handle all of the background try to keep memory usage minimal.