Loading...
 
Skip to main content

FTP Plugin and big files

Status
Closed
Subject
FTP Plugin and big files
Version
6.x
Category
  • Error
  • Patch
Feature
Wiki Plugin (extends basic syntax)
Resolution status
Partially solved
Submitted by
yajo
Lastmod by
Ushindi Gedeon
Rating
(0)
Description

Using the FTP PluginQuestion, when you try to download a big file you'll encounter an error like this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 59506688 bytes) in /home/myUser/public_html/lib/wiki-plugins/wikiplugin_ftp.php on line 65

In this case, I had tried to download a 56 MB file with a PHP memory_limit set to 128 MB on my hosting.

Solution

Using readfile instead of file_get_contents. Here's the patch:

fix FTP plugin with big files
Copy to clipboard
Index: lib/wiki-plugins/wikiplugin_ftp.php =================================================================== --- lib/wiki-plugins/wikiplugin_ftp.php (revisione 30989) +++ lib/wiki-plugins/wikiplugin_ftp.php (copia locale) @@ -61,16 +61,15 @@ ftp_close($conn_id); return tra('failed'); } - ftp_close($conn_id); - $content = file_get_contents($local); + ftp_close($conn_id); $type = filetype($local); - unlink($local); header ("Content-type: $type"); header("Content-Disposition: attachment; filename=\"$data\""); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); - echo "$content"; + readfile($local); + unlink($local); die; } else {


With this patch, I had succesfully downloaded (as a test) a 162 MB file with PHP memory_limit set to 128 MB.

Workaround
Priority
25
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
3690
Created
Thursday 02 December, 2010 16:34:14 UTC
by yajo
LastModif
Tuesday 30 June, 2026 10:28:03 UTC


Show PHP error messages