0
以下のコードはxmlファイルのダウンロードを促すように機能していません。 :私は以下の警告取得していますので、どのように私は、$データの前にヘッダを設定してください「警告:ヘッダー情報を変更することはできません - すでにによって送られたヘッダ」xmlファイルを作成し、phpでダウンロードするように強制します
private function display() {
$data ="some string";
$my_file = "sample.xml"; // name of file to be downloaded
$handle = fopen($my_file, "w");
fwrite($handle, $data);
fclose($handle);
header('Content-Type: text/xml');
header('Content-Disposition: attachment; filename='.basename($my_file));
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($my_file));
readfile($my_file);
exit;
}
Here is my ajax function
$.ajax({
url: "webservices/rest_api/display",
type: "POST",
success: function(result) {
console.log(result);
}
});
ませルイ動作するようには思えないので、同様doulbe引用符であなたのファイル名をカプセル化してみてください。早速のご返事ありがとうございます!! – suna