可能重复:
正在读取文件';s元数据
我有一个上传mp3文件的表单,但我希望用户上传音乐,mp3的所有细节,如作者、标题等,都应该自动填写在表单字段中。我使用php,想要任何php/javascript方法,可以从本地机器上找到文件名,并将该名称放在我的表单标题字段中我的表格如下。我不希望用户输入标题、作者等
<form enctype="multipart/form-data" method="post" action="http://youshare.ca/music/writestorypost"><p><span class="form_label">Name of the song</span><input type="text" value="" name="title" style="width:400px" class="inputText required"></p><p><span class="form_label">Description</span>
<textarea class="rich" style="width:580px" rows="18" name="form_content"></textarea>
</p><p><span class="form_label">Tags</span>
<input type="text" value="" style="width:300px" name="tags" class="inputText">
<span>Multiple tags should be Separated with commas(,)</span>
</p>
<p><label>Upload</label><input type="file" name="song">
<span>Only mp3 is accepted</span></p>
<p><label>Music source</label>
<input type="radio" checked="1" value="own" name="musicsource">My own
<input type="radio" value="others" name="musicsource">From another musician
</p>
<div style="display:none" id="ms_others">
<p><label>Musician name</label><input name="musician"></p>
</div>
<div id="ms_own">
<p></p>
</div>
<p><label>Picture (Optional)</label><input type="file" name="picture">
<span>A picture about the song or the musician</span></p>
<script type="text/javascript">
jQuery(document).ready(function($) {
$("input[value='own']").click(
function() {
$("#ms_others").hide();
$("#ms_own").fadeIn();
}
);
$("input[value='others']").click(
function() {
$("#ms_own").hide();
$("#ms_others").fadeIn();
}
);
})
</script><p><input type="submit" value="Submit" class="button"></p><input type="hidden" value="935" name="page_id"></form>
文件上传后,您需要填充MP3的详细信息,除非他们手动键入所有信息。
在PHP方面,您可以安装以下内容:PHP ID3
这里有一些关于如何从文件中读取ID3标记的示例。