protected void buttonUploadFile_Click(object sender, EventArgs e) { SubcatagoryTableAdapter adp = new SubcatagoryTableAdapter(); DataTable subCatagorytable = adp.GetAllSubcatagoryNames(); for (int i = 0; i < subCatagorytable.Rows.Count; i++) { if (DropDownListUpload.SelectedValue == subCatagorytable.Rows[i][2].ToString()) { if (fileupload1.HasFile) { labelUploaded.Text = "uploading..."; SubcatagoryTableAdapter catagoryadp = new SubcatagoryTableAdapter(); DataTable catagoryNamesTable = catagoryadp.GetCatagorySubcatagoryNames(DropDownListUpload.SelectedValue.ToString()); string path = Server.MapPath("Assets" + "/" + catagoryNamesTable.Rows[0][4].ToString() + "/" + subCatagorytable.Rows[i][2].ToString()); fileupload1.SaveAs(path + "/" + fileupload1.FileName); labelUploaded.Text = "File name: " + fileupload1.PostedFile.FileName + "<br>" + fileupload1.PostedFile.ContentLength + " kb<br>" + "Content type: " + fileupload1.PostedFile.ContentType; } else { labelUploaded.Text = "You have not specified a file."; } } } }
protected void buttonUploadFile_Click(object sender, EventArgs e) { SubcatagoryTableAdapter adp = new SubcatagoryTableAdapter(); DataTable subCatagorytable = adp.GetAllSubcatagoryNames(); for (int i = 0; i < subCatagorytable.Rows.Count; i++) { if (DropDownListUpload.SelectedValue == subCatagorytable.Rows[i][2].ToString()) { if (fileupload1.HasFile) { labelUploaded.Text = "uploading..."; SubcatagoryTableAdapter catagoryadp = new SubcatagoryTableAdapter(); DataTable catagoryNamesTable = catagoryadp.GetCatagorySubcatagoryNames(DropDownListUpload.SelectedValue.ToString()); string path = Server.MapPath("Assets" + "/" + catagoryNamesTable.Rows[0][4].ToString() + "/" + subCatagorytable.Rows[i][2].ToString()); fileupload1.SaveAs(path + "/" + fileupload1.FileName); labelUploaded.Text = "File name: " + fileupload1.PostedFile.FileName + "<br>" + fileupload1.PostedFile.ContentLength + " kb<br>" + "Content type: " + fileupload1.PostedFile.ContentType; } else { labelUploaded.Text = "You have not specified a file."; } } } }