Register |
Your Cart is currently empty.
Home > Forum
Welcome, Guest

PHP Memory limit & large file size
(1 viewing) (1) Guest

Dear Customers,

Feel free to submit requests if you have any questions or need assistance.

Before submitting a support request, please pay attention to the description of the corresponding product and frequently asked questions. Answers you are looking for may already be there.
When submitting a request, please include as many details on the problem as you can. This will help us understand the essence and provide you with a helpful solution.
For more information on our support conditions, view JoomPlace support policy.
THANKS FOR YOUR PATIENCE!
  • Page:
  • 1

TOPIC: PHP Memory limit & large file size

PHP Memory limit & large file size 5 years, 2 months ago #1467

  • Rick
  • OFFLINE
  • Fresh Boarder
  • Posts: 9
  • 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.

 
<?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

Re:PHP Memory limit & large file size 5 years, 2 months ago #1478

Thank you, Rick!

Vlad

Re:PHP Memory limit & large file size 3 years, 8 months ago #7991

I am trying to use files that are 250mb. How do I implement your script so it will upload in batches?

Re:PHP Memory limit & large file size 3 years, 8 months ago #7997

  • Ann
  • OFFLINE
  • Moderator
  • Posts: 2601
  • Karma: 29
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!
JoomPlace.com, JoomlaLMS.com
Tech. Support

Re:PHP Memory limit & large file size 3 years, 8 months ago #8003

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?

Re:PHP Memory limit & large file size 3 years, 8 months ago #8007

  • Ann
  • OFFLINE
  • Moderator
  • Posts: 2601
  • Karma: 29
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!
JoomPlace.com, JoomlaLMS.com
Tech. Support

Re:PHP Memory limit & large file size 3 years, 8 months ago #8025

Ok... I sent all the information to your email and to support@joomplace.com. Let me know if you dont receive the information and I will resend it. Thanks!

Re:PHP Memory limit & large file size 3 years, 8 months ago #8028

  • Ann
  • OFFLINE
  • Moderator
  • Posts: 2601
  • Karma: 29
Hi!
Here is the way the component works: there is no a direct link to the file, it's readind is performed so taht a user could download it (otherwise the limitation to download will not be implemented).

As far as the file is very large, your server doesn't have enough space to load it.
That's why you need to increase the server memory size to solve this.

Kind regards!
JoomPlace.com, JoomlaLMS.com
Tech. Support

Re:PHP Memory limit & large file size 3 years, 8 months ago #8032

The files are about 250mb... so would I have to increase the limit to 250?

Re:PHP Memory limit & large file size 3 years, 8 months ago #8047

  • Ann
  • OFFLINE
  • Moderator
  • Posts: 2601
  • Karma: 29
Hi!
Not exactly: you should try downloading the biggest file, and add memory space until you succeed in downloading.

Kind regards!
JoomPlace.com, JoomlaLMS.com
Tech. Support
  • Page:
  • 1
Moderators: Maria_B
Time to create page: 0.62 seconds