Author Topic: problem downloading big files  (Read 19370 times)

0 Members and 1 Guest are viewing this topic.

Offline k4nth

  • Newbie
  • *
  • Posts: 28
    • View Profile
problem downloading big files
« on: March 14, 2003, 07:04:14 PM »
Hi, i can't seem to download big files (500MB) using the download button.  It takes ages to respond and when it finally tries to download the file, only around 650KB is being downloaded. How can i fix this problem?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
problem downloading big files
« Reply #1 on: March 14, 2003, 07:07:12 PM »
Open download.php and locate this code:
Code: [Select]
 if (!empty($file['file_path'])) {
    @set_time_limit(120);
    if ($remote_url) {
      header("Location: ".$file['file_path']);
      exit;
    }

Try increasing 120 to 300 or some higher number.  This page documents what the set_time_limit function does:

http://www.php.net/manual/en/function.set-time-limit.php

Offline k4nth

  • Newbie
  • *
  • Posts: 28
    • View Profile
problem downloading big files
« Reply #2 on: March 14, 2003, 07:19:18 PM »
tried that, still the same problem. any other suggestions? When i opened the downloaded wmv file using notepad, i found this error message.

HTTP/1.1 400 Bad Request Date: Fri, 14 Mar 2003 18:29:45 GMT Server: Apache/1.3.27 (Unix) mod_log_bytes/1.0 mod_bwlimited/1.0 PHP/4.3.1 FrontPage/5.0.2.2510 mod_ssl/2.8.12 OpenSSL/0.9.6b Connection: close Content-Type: text/html; charset=iso-8859-1
Bad Request
Your browser sent a request that this server could not understand.
The request line contained invalid characters following the protocol string.




--------------------------------------------------------------------------------

Apache/1.3.27 Server at localhost.localdomain Port 80

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Administrator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
problem downloading big files
« Reply #3 on: March 14, 2003, 09:37:29 PM »
that's probably because 4images checking if the file exist on the server, that makes PHP load it into memory (atleast that what I have on my windows+apache server), and if in php.ini set memory limit per script is too little (2mb by default) it could cause the error.
I probably wrong, but thats my theory ;)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Chantique

  • Pre-Newbie
  • Posts: 9
    • View Profile
problem downloading big files
« Reply #4 on: May 07, 2003, 12:10:43 AM »
about movies...

do we have to use broadband to watch the movies ? i mean the connections.. cause it seems my friends who is using modem can't watch my movies and they said it keeps buffering all the time  :roll:  :(

Offline Robinini

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: problem downloading big files
« Reply #5 on: June 05, 2007, 12:19:45 PM »
I had a similar problem with files of about 6Mb. I investigated the PHP file read limit size and indeed, the download function makes use of a function which has a read limit problem for some servers. I located the download code and replaced it with a function which reads the file in chunks, eliminating the readfile limit problem.

It took ages to work out and it seems to have worked for me, and I would be interested to hear if it works for others too....

In file download.php;
Before "function get_remote_file($url) {" which is approximately line 33, insert;

function readfile_chunked($filename,$retbytes=true) {
   $chunksize = 1*(1024*1024); // how many bytes per chunk
   $buffer = '';
   $cnt =0;
   $handle = fopen($filename, 'rb');
   if ($handle === false) {
       return false;
   }
   while (!feof($handle)) {
       $buffer = fread($handle, $chunksize);
      // 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;

}


also, to refer to the alternative function, within function get_file_data($file_path) {, replace;

@readfile($file_path);


with

@readfile_chunked($file_path) ;

The readfile_chunked() function is not originally of my own hand, but extracted from http://ch2.php.net/manual/en/function.readfile.php#54295

Offline ivan

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.279
    • View Profile
    • Bilder Gallery
Re: problem downloading big files
« Reply #6 on: June 05, 2007, 07:38:12 PM »
hi Robinini
this script have a error (white screen)  in 4images 1.7.4

greets ivan
greetings / grsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery

Offline Robinini

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: problem downloading big files
« Reply #7 on: June 06, 2007, 07:05:03 AM »
Hello Ivan

I also have the same version of 4images and I have checked the code. It is exactly the same as described above and it works for me. I have no other modifications to the software.

Sorry that it does not work for you at the moment! Note that there will now be a delay before the zip file download commences. Is this what is happening with you? I'm surprised that you have a white screen.

If you like, attach a copy of your download.php and I will check the code when I next get a chance.

Robin

Offline ivan

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.279
    • View Profile
    • Bilder Gallery
Re: problem downloading big files
« Reply #8 on: June 06, 2007, 07:57:48 AM »
hi Robinini

I did not create it yesterday tried however. can I see yours download.php times?
Respectively could you let the code in the forum indicate?
Best owing to for your assistance

Greets Ivan
greetings / grsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery

Offline Robinini

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: problem downloading big files
« Reply #9 on: June 06, 2007, 09:05:14 AM »
Ivan

Attached is my download.php, but saved as .txt in case there is a problem with .php

Please note that "Robin added function2" did not work and is commented out with /* and */ so is not part of the PHP programme. I do not think that I have made any other changes to any other files. If you would like to see anything else, then ask!

Robin

 

Offline ivan

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.279
    • View Profile
    • Bilder Gallery
Re: problem downloading big files
« Reply #10 on: June 06, 2007, 10:26:40 AM »
thanks for the fast post...
i will see and testing the download script ;)

i let you again know

greets ivan
greetings / grsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery

Offline ivan

  • Moderator
  • 4images Guru
  • *****
  • Posts: 2.279
    • View Profile
    • Bilder Gallery
Re: problem downloading big files
« Reply #11 on: June 06, 2007, 09:39:19 PM »
hi
your file tested. unfortunately the same problem. I have one white screen on display.
my testing file is 160mb big.

and download jpg files have a error


Code: [Select]
Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/bildergallery.com/httpdocs/download.php:47) in /var/www/vhosts/bildergallery.com/httpdocs/download.php on line 157

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/bildergallery.com/httpdocs/download.php:47) in /var/www/vhosts/bildergallery.com/httpdocs/download.php on line 158

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/bildergallery.com/httpdocs/download.php:47) in /var/www/vhosts/bildergallery.com/httpdocs/download.php on line 170

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/bildergallery.com/httpdocs/download.php:47) in /var/www/vhosts/bildergallery.com/httpdocs/download.php on line 171

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/bildergallery.com/httpdocs/download.php:47) in /var/www/vhosts/bildergallery.com/httpdocs/download.php on line 173
�JFIF�������<{e/?]d3f�S]:^ʆSK*Z?d?i??@7F�=͉Lq � G k͌~~s|7͵ܯu/ޙ|מy' ~+}MEG.oK-] _W_qawB{nBU`8kᯍ->Qa17o;5 ' |�f?_ ռ>t۵ێd�LO~83cy~ zyKJM}cڬ#v3v6�oiWÍabDr/<λ? J*^]}]Z&�g_!8h =qUeUe6EnAYTnߊ|:ʭ1w7>nڻUGll(<>[go<*T:EǷYUg}l{TE9ƒoyo;__K/?p8͇� :�p}ز�m_<�KysCͷל}fkx�&_3u�cYޜb>+Ͼ=g�FWn>_{{Z[fkm}8V�+YU�|m{]?on_MD�/�]!8�Șzߕ{�uW[�?ll# ʣś{&8ȿh4mEů?L<=i?h} 籯G;~Uoo}w� io^9os\sz߹O?�z,| //?_kGː>6zw"z~[]Z~|ײCk#|#mվN63�iWeF߼OƸafճZu�Gk{o>-| o4He)~>5UO *M[T ='LYj:FZk-›O0E}M� Xzm~�?~~zL>_^?j &<0&7.vN5j:  etc.......

im use php 4.x
user in php.net forum says... your modifikation is only for php 5.
is this correct?

greets ivan
greetings / grsse
ivan

Facebook Fan Page | Follow Twitter

Blog: Reisen Blog
Bilder Gallery: Bilder Gallery

Offline Robinini

  • Pre-Newbie
  • Posts: 5
    • View Profile
Re: problem downloading big files
« Reply #12 on: June 07, 2007, 07:17:26 AM »
Ivan, I have tried my site with PHP Version 4.4.4 and PHP 5.1.1.

 PHP Version 4.4.4. - new download.php - Is a problem - as you have said - "Warning: Cannot modify header information - headers already sent by (output started at d:\www\www11..."

 PHP Version 5.1.1 - new download.php - Works - no problem.

This makes me think - is it only the change to PHP 5 which has made it work? I have therefore tried the combination - original 4images download.php and PHP 5.1.1.....

...and there is no problem with large files!! The lesson here is that changing to PHP 5.1.1 solves the problem!!!

Is this possible for you to do!? I would be interested to see if the large 160MB file works also.....

Robin
(It looks like I was wasting our time with the new function, but I learned a lot!)