Upload file on server without asp.net FileUpload control
In
my last interview , interviewer asked me "How to upload file on server without using FileUpload asp.net control?"
So I decided to share code with all of you guys with this way you can upload file on server without using FileUpload server control given in toolbox.
protected void btnUploadClick(object sender, EventArgs e) { HttpPostedFile file = Request.Files["myFile"]; //check file was submitted if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath(Path.Combine("~/App_Data/", fname))); } }
Comments
Post a Comment