FileUpload--未将对象引用设置到对象的实例
我用一个FileUpload控件上传图片,原先没什么问题,后来不知道为什么就突然弹出这个提示了,下面是我的代码,this.imageUpload是FileUpload控件的ID来的: 程序代码:
private void ImageUpload() { DBOperation dbo = new DBOperation(); pageFunction func = new pageFunction(); string path = this.imageUpload.PostedFile.FileName; FileInfo image = new FileInfo(path); string name = image.Name; string type = image.Extension; if (".png" == type || ".PNG" == type || ".jpg" == type || ".JPG" == type || ".gif" == type || ".GIF" == type) { string savepath = Server.MapPath("Upload"); this.imageUpload.SaveAs(savepath + "\\" + name); string dbpath = "../BgPage/Upload/" + name; dbo.InsertImage(dbpath); string insText = ""; this.editArea.Text = this.editArea.Text + insText; func.WriteScipt(this.Page, "alert('上传成功!')"); } else { func.WriteScipt(this.Page, "alert('不支持该图片类型,请选择gif、png或jpg类型的图片!')"); } }
我调试的时候,错误提示是在
string path = this.imageUpload.PostedFile.FileName; 获取完整路径有问题,但是从代码上看我实在找不出错在什么地方
有哪位高手知道怎么解决的,拜托指点一下,谢谢