Are there any best practices for limiting the size of files when saving MP3 data from a Shoutcast server using PHP?

When saving MP3 data from a Shoutcast server using PHP, it is important to limit the size of the files to prevent excessive storage usage. One way to achieve this is by setting a maximum file size limit and periodically checking the size of the file being saved. If the file exceeds the limit, you can stop saving the data to prevent oversized files.

// Set maximum file size limit (in bytes)
$maxFileSize = 10485760; // 10 MB

// Check the size of the file being saved
if (filesize($mp3FilePath) > $maxFileSize) {
    // Stop saving the data
    die('File size limit exceeded. Saving aborted.');
}