写入标签后如何保存文件?



我正在尝试使用 getID3 库更改 mp3 文件的曲目详细信息,然后我想将其保存到目录中。

写入标签后如何保存文件?

<?php
$remotefilename = 'http://musicbaap.com/public/music/Same-Beef-[Original]-Sidhu-Moose-Wala.mp3';
if ($fp_remote = fopen($remotefilename, 'rb')) {
$localtempfilename = tempnam('/tmp', 'getID3');
if ($fp_local = fopen($localtempfilename, 'wb')) {
while ($buffer = fread($fp_remote, 8192)) {
fwrite($fp_local, $buffer);
}
fclose($fp_local); 
$getID3 = new getID3;  
$tagwriter = new getid3_writetags;
$tagwriter->filename = $localtempfilename;
$tagwriter->tagformats = array('id3v1', 'id3v2.3'); 
// set various options (optional)
$tagwriter->overwrite_tags = true;
$getID3->encoding =  'UTF-8';
$tagwriter->tag_encoding = 'UTF-8';
$tagwriter->remove_other_tags = true;
// populate data array
$TagData['title'][] = 'My Song';
$TagData['artist'][] = 'The Artist';
$TagData['album'][] = 'Greatest Hits';
$TagData['year'][] = '2004';  
$tagwriter->tag_data = $TagData; 
// write tags
if ($tagwriter->WriteTags()) {
echo 'Successfully wrote tags<br>'; 
if (!empty($tagwriter->warnings)) {
echo 'There were some warnings:<br>'.implode('<br><br>', $tagwriter->warnings);
}
} else {
echo 'Failed to write tags!<br>'.implode('<br><br>', $tagwriter->errors);
} 
// dd($tagwriter);
}
fclose($fp_remote);
}

该文件具有在调用方法后写入的标记。

$localtempfilename = tempnam('/tmp', 'getID3');

这是您将文件放置在计算机上的位置,也是文件"保存"的位置。完成所需的所有操作后,更改将保存到此文件中。

相关内容

  • 没有找到相关文章

最新更新