protected void btnUpload_Click(object sender, EventArgs e) { HttpFileCollection hfc = Request.Files; // htc gives null foreach (string filetagname in hfc) { HttpPostedFile hpf = Request.Files[filetagname]; if (hpf.ContentLength > 0) { int size = hpf.ContentLength; string name = hpf.FileName; int position = name.LastIndexOf(@"\\"); name = name.Substring(position + 1); string content = hpf.ContentType; byte[] filedata = new byte[size]; hpf.InputStream.Read(filedata, 0, size); filedownload.savefile(name, content, size, filedata); } } DataTable dt = filedownload.GetFileList(); GridView1.DataSource = dt; GridView1.DataBind(); }
input type="file"
asp:FileUpload
Quote: As far as I can see, you just need to add enctype="multipart/form-data" to your form: You are not using asp:FileUpload control which adds that enctype automatically, so you should do that manually.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)