[Vtigercrm-commits] [vtiger-commits] r9480 - /vtigercrm/branches/4.2/modules/uploads/add2db.php
vtigercrm-commits at vtiger.fosslabs.com
vtigercrm-commits at vtiger.fosslabs.com
Wed Sep 13 02:34:10 EDT 2006
Author: allanbush
Date: Wed Sep 13 00:34:08 2006
New Revision: 9480
Log:
Reduced memory used during upload by base 64 encoding the uploaded file in 1MB cunks and closing file handles when we're finished with them. Refs #61.
Modified:
vtigercrm/branches/4.2/modules/uploads/add2db.php
Modified: vtigercrm/branches/4.2/modules/uploads/add2db.php
==============================================================================
--- vtigercrm/branches/4.2/modules/uploads/add2db.php (original)
+++ vtigercrm/branches/4.2/modules/uploads/add2db.php Wed Sep 13 00:34:08 2006
@@ -46,8 +46,11 @@
$filenameBase64 = $filename.".base64";
$rfh = fopen($uploaddir.$filename, "r");
$wfh = fopen($uploaddir.$filenameBase64, "w");
- //FIXME: find a way to stream data to base64_encode() to reduce memory usage -mikefedyk
- fwrite($wfh,base64_encode(fread($rfh, $filesize)));
+ while(!feof($rfh)) {
+ fwrite($wfh,base64_encode(fread($rfh, 1024*1024)));
+ }
+ fclose($rfh);
+ fclose($wfh);
deleteFile($uploaddir,$filename);
$query = "insert into crmentity (crmid,smcreatorid,smownerid,setype,description,createdtime,modifiedtime) values('";
More information about the vtigercrm-commits
mailing list