开发者

Problem with saving attached files using FileUpload control in ASP.NET

In my website,I have a home page in which by clicking on an image button,I get redirected to a different .apsx page .This page consists of a FileUpload control and 2 buttons(ATTACH,CANCEL).When a user selects/browses a file from his local machine and click ATTACH button,I display that file in a GRIDVIEW and also push the details of that file like Filename into a DATATABLE.

The user in this way can browse multiple files and all of them are added to GridView and also pushed to DATATABLE.Now when the user clickes CANCEL button,I am sending the whole DATATABLE in a session object to the HOME page.Upon clicking SAVE button in the home page,the files in the DATATABLE must get stored in a physical location that I mention in the code.

The problem that I am facing is that when I write FileUpload fl=new FileUpload;

fl.SaveAs(dt["fileName"]);

The files are not at all getting saved in the location.

However If I pass the FileUpload control using Session from the second page,

FileUpload fl=(FileUpload)Session["FileUpload"]

The files are getting sav开发者_高级运维ed with the correct filenames but the content of all the files consists of the content of the latest uploaded file.I know what the problem is but unable to get a solution.

My Requirement is to save the files in a physical path only after clicking the Save button in the home page.Kindly Suggest me..Thanks in advance!


I believe that the asp.net FileUpload control only supports uploading of one file at a time. that is why you only see the contents of the last file. You either need to create a separate control for each upload, roll your own, or use a 3rd-party vendor control.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜