ASP.NET 2.0 multi-file online experience

xiaoxiao2021-04-04  236

Want to implement the functions uploaded by the Multiple files, click a button to add a file to the box, which is previously seen on the network hard disk. JavaScript I know how to achieve any additional file controls, the problem is to add HTML controls, I don't know how to get the server to get the file. So the Google search "ASP.NET Multi-File Upload", I really found a file, the title "Upload" in ASP.NET ", the article is VB.NET implementation, the function is exactly the same," I mainly want to see how the server is getting uploaded by the client. I read the code in the article. It turns out as simple, System.Web.httpContext.current.Request.Files contains the file uploaded by the client browser, I use C # I wrote a simple code, I originally thought it should, and the result is unexpected to upload 3 pictures system.web.httpContext.current.Request.Files returned file format or 0. I don't know why, look at the code, I can't make a bit wrong, then look at another article in Google search results, I found that the first one of my see is not original, the author's website has two instances A version, one is VB.Net one is C #, now I don't have to write it yourself, copy the original code to the local, run, really, how can I write the code? Repeatedly compares the difference between my code and the code in the article, I tried a few places, and I finally found that there is no relationship with other places. The reason is in the

ENCTYPE attribute, there is no attribute in the VS 2005, and there is an instance of the article, I will add EncType =" multipart / form-data "system.web.httpContext.current.request.Files Energy to acquire the number of files normally. Probably the page built by the VS 2003 has this property, otherwise the author of this important attribute author should be mentioned in the article. reference:

"Implement multi-file upload in ASP.NET"

I do the test code:

<% @ Page language = "c #" autoeventwireup = "true" codebehind = "default.aspx.cs" inherits = "demo._default"%>%>