I have the following PHP code that outputs a document from a web service:
$db->where('documentReference', $post->documentID); $results = $db->getOne('documents'); $filelocation = 'doc/'; $file = $results['filename']; header('Content-type: application/vnd.openxmlformats-officedocument.wordprocessingml.document'); header('Content-Length: ' . filesize($filelocation.$file)); header('Content-disposition: attachment; filename="'.$file.'"'); readfile($filelocation.$file);
And on the front side.
APIService.registerUser($scope.formData).then(function(data){ var blob = new Blob([data.data], {type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'}); var config = { data: blob, filename: 'test.docx' }; FileSaver.saveAs(config); }); }
When I check the data returned from the API, the document is returned in order, but is it always empty when saved?
source share