Skip to content
Advertisement

Save CSV Export to Server

I have the code below which triggers when a button is pressed in the WordPress admin panel. This opens a csv file called ‘ss-stock-export.csv’.

How can I save this file to my server in my uploads directory at wp-content/uploads/exports/? I tried to use file_put_contents but that doesn’t seem to be working right. The CSV file appears in the right spot but it is blank. Possibly something wrong with my $output?

JavaScript

Advertisement

Answer

This did the trick

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement