I am developing a project with React and writing the services in the backend with PHP. I added a button to the frontend and triggered the following function.
const ProcessClicheExport = (postData) => { const response = axios.post('http://localhost/OsosProject/ososAPI/processor.php?process=ProcessClicheExport' , JSON.stringify(postData) , {'headers': {'Authorization': Cookie } } ).then((response) => { /// Response }) }
On the PHP side, I created the xlsx file using the "phpspreadsheet" class. I can save this on the server side. But how can I send it to client side with REST API and force auto download on client side?In summary, I need help on both sides (React and PHP).
case "ProcessClicheExport":{ /// ..... file creation process (.xlsx) $writer = new Xlsx($spreadsheet); $writer->save('Test.xlsx'); break;}