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を使用)
ありがとうございました!もう1つの質問ですが、ファイルをダウンロードするためのリンクを送信すると、ファイル名またはsubtitleStringが必要ですか? – wallypg
ファイルを保存したサーバーに置くためのリンクであるため、filenameが必要です。 –