On my website, I have implemented an ajax control upload event that allows users to upload a zip file and then unzip it using zlib. The folder name for unzipping is created based on the selection from a dropdown list. However, I am facing some issues where the default value "CEESI" is always selected when the page loads, causing the folder to be named incorrectly. Even if a different option is chosen from the dropdown list during the ajax upload, the selected input is not recognized for creating the folder name, resulting in an error stating that the path does not exist. The upload and unzip functionality only works for the default dropdown list input "c".
Here is a snippet of my ASPX source:
<asp:DropDownList ID="DropDownList1" runat="server" Font-Size="Smaller">
<asp:ListItem>c</asp:ListItem>
<asp:ListItem>n</asp:ListItem>
<asp:ListItem>h</asp:ListItem>
<asp:ListItem>f</asp:ListItem>
<asp:ListItem>ce</asp:ListItem>
<asp:ListItem>si</asp:ListItem>
</asp:DropDownList>
Below is a snippet of my C# code (aspx.cs):
protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
string path_with_file_name = null;
try
{
_path = Server.MapPath("~/App_data" + "/" + get_user_data(1) + "/" + DropDownList1.Text + "/");
bool isExists = System.IO.Directory.Exists(_path);
if (!isExists)
System.IO.Directory.CreateDirectory(_path);
path_with_file_name = _path + e.FileName;
AjaxFileUpload1.SaveAs(Path.Combine(_path, e.FileName));
}
catch (UnauthorizedAccessException Uae)
{
throw Uae;
}
UnZipper uz = new UnZipper();
uz.Destination = _path;
uz.IfFileExist = enIfFileExist.Overwrite;
uz.ItemList.Add("*.*");
uz.Recurse = true;
uz.ZipFile = @path_with_file_name;
uz.UnZip();
}