Please help me.......MIME Type for XLS file
-
Dear Friends, I have written the following code to upload .xls file. I want to upload only .xls file. if (fuploadPaySlip.HasFile) { if (fuploadPaySlip.PostedFile.ContentType == "application/x-msexcel") { fuploadPaySlip.PostedFile.SaveAs(Server.MapPath(".") + "//uploadedfiles//" + fuploadPaySlip.FileName); lblErrorMsg.Text = "Uploaded Successfully"; } else lblErrorMsg.Text = "Not a valid File"; } else lblErrorMsg.Text = "No File is Selected"; but it is always saying "Not a valid file". I have even tried with other MIME Types like application/excel application/vnd.ms-excel application/x-excel Still I am getting error. Please anyone can help me. Its very urgent. Regards, Dileep.
-
Dear Friends, I have written the following code to upload .xls file. I want to upload only .xls file. if (fuploadPaySlip.HasFile) { if (fuploadPaySlip.PostedFile.ContentType == "application/x-msexcel") { fuploadPaySlip.PostedFile.SaveAs(Server.MapPath(".") + "//uploadedfiles//" + fuploadPaySlip.FileName); lblErrorMsg.Text = "Uploaded Successfully"; } else lblErrorMsg.Text = "Not a valid File"; } else lblErrorMsg.Text = "No File is Selected"; but it is always saying "Not a valid file". I have even tried with other MIME Types like application/excel application/vnd.ms-excel application/x-excel Still I am getting error. Please anyone can help me. Its very urgent. Regards, Dileep.
Try:
ContentType = "application/vnd.xls";
Another thought to the issue, you using Office 2003 or 2007? Both have different extensions to excel files, might that be the reason!