I have some web application which save files in DB as a binary and I use the following code:
string contentType = FileUpload1.PostedFile.ContentType;
// Get the bytes from the uploaded file
byte fileData = new byte[FileUpload1.PostedFile.InputStream.Length];
FileUpload1.PostedFile.InputStream.Read(fileData, 0, fileData.Length);
// Get the name without folder information from the uploaded file.
string originalName = Path.GetFileName(FileUpload1.PostedFile.FileName);
// Create a new instance of the File class based on the uploaded file.
File myFile = new File(contentType, originalName, fileData);
// Save the file, and tell the Save method what data store to use.
the problem is when I try to get the file from DB of content type =plain/text to view them the IE and the Firefox browsers couldn't disply them and I get the folowing erroe in the IE
"Invalid at the top level of the document. Error processing resource"
the code which I used to view is like the following:
Guid id = new Guid(Request.QueryString.Get("Id"));
File myFile = File.GetItem(id);
Response.ContentType = myFile.ContentType;
please if any body get what I mean and can help me please send me or tell me about some URL may help me in solving this issue