Why is the File Download Action Downloading My HTML Page Source?

Hi there @teodor

I have a server action report_activity.php which does an Export CSV File function:

file_export

Where

attendee_list_url = 'file_downloads/activity-report-test-1-report-attendees.csv'

It correctly creates the csv file in my file_downloads directory.

When this server action completes, it runs the following dmx-download:

<dmx-download id="report_activity_attendee_list_download" 
dmx-bind:filename="report_activity.data.attendee_list_filename" 
dmx-bind:url="report_activity.data.attendee_list_url">
</dmx-download>

Where these are the values being used:

report_activity.data.attendee_list_filename = 'activity-report-test-1-report-attendees.csv'
report_activity.data.attendee_list_url = 'file_downloads/activity-report-test-1-report-attendees.csv'

However the file that is downloaded from the browser is the page’s HTML source code, not the .csv file.

This is being executed from my index.php file with a file structure like this:

site_root
   index.php
   file_downloads/
      activity-report-test-1-report-attendees.csv

I’ve used this method before in another part of my app and all has worked well… what am I doing wrong here? :thinking:

Best wishes,
Antony.

Is it really the html of the index page or perhaps the html from a 404 error page. It is possible that some rewrite rule in your .htaccess is causing it or perhaps the file didn’t finish writing its content when you are trying to download it.

Hi there @patrick

it is a totally weird combo of parts of my app… I’ll DM it to you!