Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用angularjs从PHP REST API下载docx文件_Php_Angularjs_Rest_Slim_Phpword - Fatal编程技术网

使用angularjs从PHP REST API下载docx文件

使用angularjs从PHP REST API下载docx文件,php,angularjs,rest,slim,phpword,Php,Angularjs,Rest,Slim,Phpword,我有一个用SLIM框架编写的PHP REST API,我有一个API调用,它创建一个docx文件并强制下载该文件。 $filename = 'invitation.docx'; $templateProcessor->save($filename); header('Content-Description: File Transfer'); header('Content-type: application/force-download'); header('Co

我有一个用SLIM框架编写的PHP REST API,我有一个API调用,它创建一个docx文件并强制下载该文件。 $filename = 'invitation.docx'; $templateProcessor->save($filename); header('Content-Description: File Transfer'); header('Content-type: application/force-download'); header('Content-Disposition: attachment; filename='.basename($filename)); header('Content-Transfer-Encoding: binary'); header('Content-Length: '.filesize($filename)); ob_clean(); ob_flush(); readfile($filename); exit();
有人有想法吗?

我也有同样的问题。只需在get配置中添加
responseType:'arraybuffer'

  Data.get('downloadInvitation/'+ id).then(function(results) {
        var file = new Blob([results], { type:    'application/vnd.openxmlformats-officedocument.wordprocessingml.document' });
       saveAs(file, 'invitation.docx');
       });