這是winform上的代碼
private void button2_Click(object sender, EventArgs e)
{
System.Net.WebClient myWebClient = new System.Net.WebClient();
OpenFileDialog of = new OpenFileDialog();
if (of.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
FileInfo fileinfo = new FileInfo(of.FileName);
}
string fileName = of.FileName;
myWebClient.UploadFile("file:///E:\\TEST\\testclient\\HandleUpImage.ashx", "POST", fileName );
MessageBox.Show("ooooook");
}
//這是原本ashx上的代碼
public class Uploader : IHttpHandler
7.{
8. public void ProcessRequest(HttpContext hc)
9. {
10. foreach (string fileKey in hc.Request.Files)
11. {
12. HttpPostedFile file = hc.Request.Files[fileKey];
13. file.SaveAs(Path.Combine(hc.Server.MapPath("."), file.FileName));
14. }
15. }
16.
17. public bool IsReusable
18. {
19. get { return true; }
20. }
21.}
點擊了按鈕 ,再用ie打開ashx顯示上傳圖片是成功的,但是我再用VS2010打開ashx,裡面就不是代碼了,而是這樣的
這是正常的嗎 那我不能再用這個ashx的文件了?要用只能將這些全部刪掉 重新寫代碼?
怎麼感覺你上傳的文件內容寫入到ashx裡面了。。而且file:///E:\TEST\testclient\HandleUpImage.ashx你這種路徑也有問題吧。。無法編譯吧。。