• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

File download wrapped by page container

I'm porting some content over from vBulletin that works basically like this:

Visitor selected a choice from a select dropdown, which then loaded a separate PHP file in an iFrame to download a file. This was to a.) keep the page and file selection tidier, and b.) to keep the folder where the files are located hidden.

This works fine in my add-on, except that the file name is being appended with .html, and the file contents itself are being wrapped with a basic page container which breaks the file.

Some example code to show what I mean:

<iframe name="downloader" id="downloader"></iframe>

<script type="text/javascript">
//below code is called when a select option is focused, sending a post form submission within the iframe above
$('body').append('<form action="{xen:link dsdt/index}" method="post" class="xenForm" data-redirect="yes" target="downloader" id="postToIframe"></form>');
                    $('#postToIframe').append('<input type="hidden" name="do" value="get" />');
                    $('#postToIframe').append('<input type="hidden" name="filename" value="'+$(this).val()+'" />');
                    $('#postToIframe').append('<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />');
And within my ControllerPublic class for the add-on:

//when $myData["do"]=="get"
$filename = $myData['filename'];
                    @header("Content-Disposition: attachment; filename=$filename");
                    @header("Content-type: application/aml");
                    $viewParams = array();
                    return $this->responseView('DsdtDatabase_ViewPublic_DsdtDatabase', '', $viewParams);
All of the above works fine to download the file, though it doesn't matter what format the file is in (I've tried zipping everything as well).

We're going to be purchasing the Resource Manager add-on for software downloads, though I'd rather keep this separate from that.

Thanks for the help!