How will you upload a file to IIS in Asp and how will you do the same in ASP.net?

 Posted by Rohitshah on 10/7/2008 | Category: ASP.NET Interview questions | Views: 5854
Answer:

First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old <input tag, with the type set to File, such as <input type=file id=”myFile” runat=server />. This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server.

myFile.PostedFile.SaveAs ("DestinationPath")

Note: The Form should have the following ENC Type
<form enctype="multipart/form-data" runat="server">


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response