Leave off all the HTML stuff and header. You should send the file content as the ONLY content of the response, and set the headers accordingly. You can't mix HTML and random other data in the same response. An html response is normally just a single "file" or bit of content.