Asp.net fileupload control postback problems

2019-08-17 00:34发布

using ASP.net, vs2008 C#.

Im using a FileUpload control on a webform. The uploading of a file (ie PDF dcouments) to a server directory works ok.

I have on the webform a "preview" button that the user can use to preview the PDF file after they have selected it via the Fileupload browse feature. I do this by

  if (this.FileUpload1.HasFile)
      {
        localURL = FileUpload1.PostedFile.FileName;
        // use this to preview file. Other methods are restricted by local security requirements
        Process.Start(localURL);
      }

My problems is that after the button click Postback occurs the location of the selected file disappears from the textbox part of the Fileupload control.

How can i keep this info there, so the user does not have to browse again and instead can just click upload to upload the file.

Any help appreciated

thanks

1条回答
啃猪蹄的小仙女
2楼-- · 2019-08-17 01:00

try putting the localURL variable into a session. worked for me once

查看更多
登录 后发表回答