[SOLVED] Apache does not deliver a big file

Found any bugs with any of our scripts? Post in here...

[SOLVED] Apache does not deliver a big file

Postby fels » Thu Apr 14, 2011 2:19 pm

I have allowed for 1024M upload size, upload happens successfully, but download fails.
This happens for a file with about 900MB; a smaller file withabout 200MB can be uploaded and downloaded.

Opera Error page:

----
Remote server or file not found

You tried to access the address http://vm178.rz.uos.de:8081/dfh/downloa ... ce5ddf44a9, which is currently unavailable. Please make sure that the web address (URL) is correctly spelled and punctuated, then try reloading the page.
...
---

Does anybody know how to tweak php.ini and apache.conf to cooperate?
Do you reccommend another web server (nginx, lighttpd with cgi-support) ?)

Some interesting php.ini values:

short_open_tag = On
max_execution_time = 60
max_input_time = 60
memory_limit = 256M
error_reporting = E_ALL
display_errors = Off
log_errors = On
file_uploads = On
upload_tmp_dir = /data/dfh/tmp
upload_max_filesize = 1024M
post_max_size = 1024M
...


Apache error_log.
[Thu Apr 14 16:05:39 2011] [error] [client 131.173.61.235] File does not exist: /var/www/html/dfh/img/captcha-a.png, referer: http://vm178.rz.uos.de:8081/dfh/downloa ... .1_OSX.dmg
[Thu Apr 14 16:06:17 2011] [error] [client 131.173.61.235] PHP Notice: Undefined variable: rating in /var/www/html/dfh/ratingbar.php on line 43, referer: http://vm178.rz.uos.de:8081/dfh/admin.php
[Thu Apr 14 16:06:17 2011] [error] [client 131.173.61.235] PHP Notice: Undefined index: width in /var/www/html/dfh/ratingbar.php on line 12, referer: http://vm178.rz.uos.de:8081/dfh/admin.php
[Thu Apr 14 16:06:17 2011] [error] [client 131.173.61.235] PHP Notice: Undefined index: height in /var/www/html/dfh/ratingbar.php on line 13, referer: http://vm178.rz.uos.de:8081/dfh/admin.php
[Thu Apr 14 16:07:10 2011] [error] [client 131.173.61.235] File does not exist: /var/www/html/dfh/img/button03.gif\\, referer: http://vm178.rz.uos.de:8081/dfh/downloa ... ecific.EXE
[Thu Apr 14 16:07:10 2011] [error] [client 131.173.61.235] File does not exist: /var/www/html/dfh/\\"img, referer: http://vm178.rz.uos.de:8081/dfh/downloa ... ecific.EXE
[Thu Apr 14 16:07:10 2011] [error] [client 131.173.61.235] File does not exist: /var/www/html/dfh/img/captcha-a.png, referer: http://vm178.rz.uos.de:8081/dfh/downloa ... ecific.EXE
fels
Premium
 
Posts: 7
Joined: Fri Apr 01, 2011 12:13 pm

Re: Apache does not deliver a big file

Postby fels » Thu Apr 14, 2011 3:00 pm

Found the reason (?):

It seems as if DFH needs filesize as (PHP-) memory; I changed:
memory_limit = 1024M
(processing time might be worth a look, too)

... and the big file (900MB) went through.

Could this be solved in some another way?
(mod_deflate, x-sendfile, ... or any other idea)

Regards Frank
fels
Premium
 
Posts: 7
Joined: Fri Apr 01, 2011 12:13 pm

Re: Apache does not deliver a big file

Postby SamEA » Fri Apr 15, 2011 2:07 pm

fels wrote:Found the reason (?):

It seems as if DFH needs filesize as (PHP-) memory; I changed:
memory_limit = 1024M
(processing time might be worth a look, too)

... and the big file (900MB) went through.

Could this be solved in some another way?
(mod_deflate, x-sendfile, ... or any other idea)

Regards Frank


All files are processed by PHP and therefore all files uploaded must follow PHP's configuration (php.ini), however the php.ini file may be adjusted or modified by the .htaccess method or by directly modifying the php.ini file itself. Contact your web hoster for more assistance on modifying the PHP's configuration file.
SamEA,
DaddyScripts' Admin & Developer.

Require a PHP or general IT freelancer? Don't hesitate to PM me.
User avatar
SamEA
Site Admin
 
Posts: 1165
Joined: Sat Feb 19, 2011 7:51 pm

Re: [SOLVED] Apache does not deliver a big file

Postby javaboon » Sat Jul 30, 2011 5:21 pm

hmm i have had the same problems, i am serving 2000mb+ files. the whole file is read into memory before served. perhaps a chunked download would be better

Code: Select all
<?php
  define('CHUNK_SIZE', 1024*1024); // Size (in bytes) of tiles chunk

  // Read a file and display its content chunk by chunk
  function readfile_chunked($filename, $retbytes = TRUE) {
    $buffer = '';
    $cnt =0;
    // $handle = fopen($filename, 'rb');
    $handle = fopen($filename, 'rb');
    if ($handle === false) {
      return false;
    }
    while (!feof($handle)) {
      $buffer = fread($handle, CHUNK_SIZE);
      echo $buffer;
      ob_flush();
      flush();
      if ($retbytes) {
        $cnt += strlen($buffer);
      }
    }
    $status = fclose($handle);
    if ($retbytes && $status) {
      return $cnt; // return num. bytes delivered like readfile() does.
    }
    return $status;
  }

  // Here goes your code for checking that the user is logged in
  // ...
  // ...
 
  if ($logged_in) {
    $filename = 'path/to/your/file';
    $mimetype = 'mime/type';
    header('Content-Type: '.$mimetype );
    readfile_chunked($filename);
  }
  else {
    echo 'Tabatha says you haven\'t paid.';
  }
?>


code stolen from the internet :-)
javaboon
Premium
 
Posts: 34
Joined: Sat Feb 26, 2011 7:13 pm


Return to Bug Tracker

Who is online

Users browsing this forum: No registered users and 7 guests

cron