Force Download a file using an Ajax request or Task The following code doesn't seem to work when called using an Ajax or Task but it does work otherwise:

craft()-&gt;request-&gt;sendFile($file, IOHelper::getFileContents($file), array('forceDownload' =&gt; true));


I was wondering, Is it not possible to force download a file using an Ajax or Task?

Any help much appreciated!

Many thanks
I don't think you'll be able to use Craft's HttpRequestService-&gt;sendFile() for this.  But there are plenty of non-Craft ways of doing this, depending on your specific requirements.