我正在嘗試創建一個可以上傳播客的頁面。我想擁有“發布”或“取消發布”的能力。我讓每個播客添加到一個數據庫中,包含它的信息和發布列,可以是真是假。目前我使用以下代碼PHP:
if(isPublished()){
header('Cache-Control: max-age=100000');
header('Content-Transfer-Encoding: binary');
header('Content-Type: audio/'.$fileExt.''); // sets the output content type to wav
header('Content-Length: ' . filesize($podL)); // sets the legth of the file (in order to the HTML5 player to access the audio duration)
header('Accept-Ranges: bytes');
header('Content-Disposition: inline; filename="'.$podID.".".$fileExt.'"'); // set an output file name
readfile($podL); // reads the file
}
HTML音頻控件鏈接到php play audio頁面:
" type="audio/<?php echo $podE; ?>">
播客存儲在一個podcast文件夾中,我使用了htaccess Deny All,這樣文件就不能直接訪問了。
如果內容發布了,我不在乎是否有人可以下載。我只想給作者一個暫停發布或取消發布的能力,而不必刪除整個內容。
這是我為文章所做的,但是它們完全存在于數據庫中。我懷疑我可以做一些類似的事情,但是在網上找不到任何解決方法。使用readfile()我不必擔心內存問題。
$.post("read.inc.php", {
aid: aid
}, function(data, status){
if (data.includes("error: not published")) {
$("#title").append("
Article is Unavailable/Not Published
");} else {
const explData = data.split("|");
const title = explData['0'];
const author = explData['1'];
const datetime = explData['2'];
const postTime = new Date(datetime*1000);
const stringStuff = explData['3'];
$("#title").append("
"+title+"
");$("#author").append("Author: "+author);
$("#postTime").append("Published: "+postTime);
const deltaStuff = JSON.parse(stringStuff);
quill.setContents(deltaStuff);
}
});