I need to combine several mp3 files into one.
I am currently doing this:
$combinedFiles = "";
$dir = $_POST['dir'];
if ($handle = opendir($dir)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$combinedFiles .= file_get_contents(urldecode($dir."/".$entry));
}
}
closedir($handle);
}
file_put_contents("mp3/".$dir.".mp3", ($combinedFiles));
If I do this:
ini_set('memory_limit', -1);
it works. I tried to set this limit to 4 MB and it does not produce memory errors, but the file is not created. Without setting any restrictions and leaving the default, I get memory memory errors. I do not want to leave it on -1, as I read that this is bad practice and can lead to problems.
Thank you (the error does not come anywhere in the code, I run it only).
Edit: even when setting to 8 GB, which is my computer memory, it does not work.