Register |
Your Cart is currently empty.
Joomla! © Copyright
Welcome, Guest
Please Login or Register.    Lost Password?

PHP Memory limit & large file size
(1 viewing) (1) Guest
Go to bottomPage: 12
TOPIC: PHP Memory limit & large file size
#1467
PHP Memory limit & large file size 3 Years, 3 Months ago Karma: 0
The current code in this component is limited when downloading large files (over 20mb).
Many servers are using the PHP memory limit set to aprox 15 to 25 mb which effectively limits the size of the download.
The current code using "readfile" will load all of the file into memory vs say "readfile_chunked" which passes only the chunk size into memory and then flushes the memory to load another chunk.
Currently the Virtuemart native download code uses this method. Also what ever Docman is using is also working to avoid this download limitation.

Code:


<?php 
function readfile_chunked($filename,$retbytes=true) { 
   $chunksize = 1*(1024*1024); // how many bytes per chunk 
   $buffer = ''; 
   $cnt =0; 
   // $handle = fopen($filename, 'rb'); 
   $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; 


?> 


I have had to use an htaccess hack as a workaround for this code limitation. My issue is that using the hack works for one or two downloads BUT, given 30 to 50 downloads at the same time will cause a memory problen in PHP. This is why the PHP memory limit is in place...to protect it from scripts using all its memory up and therefore disabling its normal operation.
Please take this as a suggestion for your next version to make this code compatible both with the Virtuemart downlaod code and also as a great stand alone component.
Thank-you for your support...
Rick
mgrick
Fresh Boarder
Posts: 9
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#1478
Re:PHP Memory limit & large file size 3 Years, 3 Months ago Karma: 2
Thank you, Rick!

Vlad
Vladimir
Moderator
Posts: 429
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#7991
Re:PHP Memory limit & large file size 1 Year, 9 Months ago Karma: 0
I am trying to use files that are 250mb. How do I implement your script so it will upload in batches?
djmweb
Junior Boarder
Posts: 20
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#7997
Re:PHP Memory limit & large file size 1 Year, 9 Months ago Karma: 25
Hi!
You should upload the file to the server via FTP, and then it will be available in the list.
Please try and see.

Kind regards!
Ann
Moderator
Posts: 2426
graph
User Online Now Click here to see the profile of this user
Gender: Female
The administrator has disabled public write access.
JoomPlace.com, JoomlaLMS.com
Tech. Support
 
#8003
Re:PHP Memory limit & large file size 1 Year, 9 Months ago Karma: 0
I uploaded the file through FTP but when I select the file using the component it just times out and logs me out of the site. I can upload files that are under 10mb.

Which php file do I need to edit to add your script?
djmweb
Junior Boarder
Posts: 20
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
#8007
Re:PHP Memory limit & large file size 1 Year, 9 Months ago Karma: 25
HI!
The component shouldn't time out and log you out of the site.
Would you be able to provide us with the admin access to your site? You can mail it to support@joomplace.com, also posting into the message this post thread's link.

We'll look into the reason for this and fix it.
Kind regards!
Ann
Moderator
Posts: 2426
graph
User Online Now Click here to see the profile of this user
Gender: Female
The administrator has disabled public write access.
JoomPlace.com, JoomlaLMS.com
Tech. Support
 
Go to topPage: 12
Moderators: admin, Ann