protected void UploadFile(object sender, EventArgs e)
{
if (fileUpload.HasFile)
{
if (fileUpload.PostedFile.ContentType == "text/xml")
{
Stream inputstream = fileUpload.PostedFile.InputStream;
byte[] streamAsBytes = (ConvertStreamToByteArray(inputstream));
string stringToSend = BitConverter.ToString(streamAsBytes);
xmlstream.Value = stringToSend;
sendXML.Visible = true;
infoLabel.Text = string.Empty;
/*
string path = Server.MapPath("GenericHandler.ashx");
WebClient wc = new WebClient();
wc.UploadFile(path,"POST", fileUpload.PostedFile);
Something like this maybe? But is there any way to do it without saving the file? */
}
else
{
infoLabel.Text = "Please select an XML file";
sendXML.Visible = false;
}
}
}
這是我當前的代碼。 xml以十六進制字符串的形式保存在隱藏字段中,並通過jquery ajax發送。但是發送文件本身並在處理程序中處理它會好得多。那可能嗎?使用http-post發送xml文件到處理程序
請不要」 t以「asp.net c#:」爲前綴。這就是我們所有的標籤[所以]。 –