1

I have an AJAX file uploader on my page, and use this to store various different file types into a database, However when I store a .rtf file and then try to output this using response, I get a file corrupt and cannot be opened error message. The file uploader automatically detects the mime type of the file on upload and stores the file as "application/msword" as this didn't work I tried giving it several other mime types however none of them worked.

Does anyone know of any reasons why this file may be corrupt?

PS. I have also tried uploading several different .rtf files with text, no text and images, etc. however none of them worked. output code below:

        context.Response.Clear();
        context.Response.ClearHeaders();
        context.Response.ClearContent();
        context.Response.ContentType = displayFile.MimeType;
        context.Response.AddHeader("content-disposition", "attachment; filename=" + displayFile.FileName); 
        context.Response.BinaryWrite(displayFile.Data);
        context.Response.End();
  • What exactly is displayFile? – Paul Zahra Jul 11 '14 at 10:14
  • Try putting a control which supports rich text format on the page and write the content to that, as you are trying to output rtf directly in the response you are experiencing the fact that rtf output into html may well need conversion else it will look corrupted. Have a read of http://stackoverflow.com/questions/439301/convert-rtf-to-html – Paul Zahra Jul 11 '14 at 10:19

0 Answers0