0
我有一個觸發文件下載表格:檢索值
function downloadEnhancedSubtitle ($subtitle,$totalSequences,$filename) {
// Build string
$subtitleString = '';
foreach ($subtitle as $thisSegmentKey => $segment) {
$sequenceString = $segment->sequence."\r\n";
$sequenceString .= formatMilliseconds($segment->startTimeInMilliseconds).' --> '.formatMilliseconds($segment->endTimeInMilliseconds)."\r\n";
if(isset($segment->textLine1)) $sequenceString .= utf8_decode($segment->textLine1)."\r\n";
if(isset($segment->textLine2)) $sequenceString .= utf8_decode($segment->textLine2)."\r\n";
if(isset($segment->textLine3)) $sequenceString .= utf8_decode($segment->textLine3)."\r\n";
$sequenceString .= "\r\n";
$subtitleString .= $sequenceString;
}
$subtitleString .= ($totalSequences+1)."\r\n99:99:90,000 --> 99:99:99,999\r\nEnhanced\r\n";
// Download string
header("Content-Type: text/plain;charset=windows-1252");
header('Content-Disposition: attachment; filename="'.$filename.'"');
header("Content-Length: " . strlen($subtitleString));
echo $subtitleString;
}
用戶提交的字幕文件,並在服務器上的「優化」,併發送回用戶作爲附件下載。但是,我希望在同一時間(相同的窗體視圖,下載文件的位置)觸發一個包含該過程的一些數據的模式,例如,優化了多少行。由於「Content-Disposition:attachment」自動下載屏幕上打印的所有內容,有沒有什麼方法可以使用該響應檢索變量的值?也許改變一切是一個Ajax請求? (在後端使用PHP)
謝謝!還有一個問題,如果我發送鏈接下載文件,我需要文件名還是subtitleString? – wallypg
您需要文件名,因爲它是放置在您保存文件的服務器上的鏈接。 –