CakePHP 内でファイルとフォルダーを操作しています。今ではすべてがうまく機能し、希望どおりに機能しています。ただし、ファイルを圧縮すると、次のエラー メッセージが表示されます。
Error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 240047685 bytes)
小さなファイルを圧縮するようになりました。問題ありません。サイズが約 10MB のファイルでも問題なく実行できましたが、サイズが大きい圧縮には問題があるようです。
今、私は .htaccess ファイルに以下を追加し、php.ini ファイルを作成しました。
php_value upload_max_filesize 640000000M
php_value post_max_size 640000000M
php_value max_execution_time 30000000
php_value max_input_time 30000000
PHPが4GBのファイル制限であるという事実を指摘する投稿を見つけるまで。その場合でも、なぜ私のzipファイルはこのファイルを実行しないのですか(約245MBしかありません)。
public function ZippingMyData() {
$UserStartPath = '/data-files/tmp/';
$MyFileData = $this->data['ZipData']; //this is the files selected from a form!
foreach($MyFileData as $DataKey => $DataValue) {
$files = array($UserStartPath.$DataValue);
$zipname = 'file.zip';
$zip = new ZipArchive();
$zip_name = time().".zip"; // Zip name
$zip->open($zip_name, ZipArchive::CREATE);
foreach ($files as $file) {
$path = $file;
if(file_exists($path)) {
$zip->addFromString(basename($path), file_get_contents($path));
} else {
echo"file does not exist";
}
} //End of foreach loop for $files
} //End of foreach for $myfiledata
$this->set('ZipName', $zip_name);
$this->set('ZipFiles', $MyFileData);
$zip->close();
copy($zip_name,$UserStartPath.$zip_name);
unlink($zip_name); //After copy, remove temp file.
$this->render('/Pages/download');
} //End of function
私が間違っている場所のアイデアはありますか? これは私のコードではないと述べます。他の投稿でその一部を見つけ、プロジェクトのニーズに合わせて変更しました!
すべてのヘルプ大歓迎...
ありがとう
グレン。