Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3641

File downloading with React Axios and PHP Rest API

$
0
0

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;}

Viewing all articles
Browse latest Browse all 3641

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>