I want to write a general file upload function in C#. My website has more than 20 columns divided into tabs consisting of nearly 8 – 10 file upload controls.
I would like to write a general method into which i could pass the fileupload control, posted file & location to be saved. How do i pass the fileupload control to a method ?
public string uploadMethod(HttpPostedFile file, <fileUpload control>, string saveLocation)
{
//saving code
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
uploadMethod(FileUpload1.PostedFile, <fileUpload control>, saveFolder)
}
I know how to save the path but have no clue how to pass a fileupload control as a parameter to a method. Would be grateful for your help 🙂
I’ve got the answer after playing around a bit. Following is the solution…
And this is how we pass the parameters to the function…
Hope this helps 🙂