1
Reply

File Upload Control doesn't keep Files

Morcos Adel

Morcos Adel

Oct 17 2011 5:58 AM
1.3k
Hello Experts,
i have a problem using the fileupload control,
Scenario :
i have a preview button which allow the user to preview the uploaded file,the preview button opens a new window with the content of that file,but when i close the popup window the fileuploader no longer have the file,so i have to choose it again...

here is the code for the preview button:

protected void PreviewLink_Click(object sender, EventArgs e)
        {
            if (ReportUpload.HasFile == true)
            {
                if (Path.GetExtension(ReportUpload.PostedFile.FileName) == ".csv")
                {
                    String FileSavePath =                           Server.MapPath("~/Uploads/Reports/Files/");
                    String FileName = ReportUpload.FileName;
                    String FullFilePath = FileSavePath + FileName;
                    ReportUpload.SaveAs(FullFilePath);

                    Session["CSVPreview"] =                    Excel.ConvertToHtmlFile(Excel.ReadExcel(FileSavePath, ".csv"));
                    
                    string script = "window.open('"+"ExcelPreview.aspx"+"','')";  
                    if (!ClientScript.IsClientScriptBlockRegistered("NewWindow"))  
                    {  
                        ClientScript.RegisterClientScriptBlock(this.GetType(),                         "NewWindow", script, true);  
                    }  

                }
            }
                
        }
any ideas?

Answers (1)