![](https://csharpcorner-mindcrackerinc.netdna-ssl.com/UploadFile/abhikumarvatsa/list-controls-in-Asp-Net-part-53/Images/List5.gif)
Asp.net File Upload Control Loses File On Postback
You can't do this for security reasons, if the control kept its filename then that would mean you could set a default filename, and if you could set a default filename then malicious websites could trick you into uploading known files. There's no point asking if there is a way around this as if there was a way around it then malicious sites would use it. Instead you need to re-architect how your page works such that you don't need to maintain the file upload state. For example if the postback is to add new upload controls then you could add the new controls via javascript to avoid the postback, or add say 10 upload controls but hide 9 and then rather than add new controls you simply show one of the hidden ones and so on.
Or you split your process in two so they do everything that doesn't involve file uploads, and then in a second stage do the file uploads. When answering a question please: • Read the question carefully. • Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. C program for sjf non preemptive scheduling.
• Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.
Free soundfont downloads. You can't do this for security reasons, if the control kept its filename then that would mean you could set a default filename, and if you could set a default filename then malicious websites could trick you into uploading known files. There's no point asking if there is a way around this as if there was a way around it then malicious sites would use it. Instead you need to re-architect how your page works such that you don't need to maintain the file upload state.
Apr 23, 2013 Hi, I have fileupload control in webpage and couple of control with autopostback true, if you select a file in fileupload control and page postback with postback control then file upload control lose the selected file.
For example if the postback is to add new upload controls then you could add the new controls via javascript to avoid the postback, or add say 10 upload controls but hide 9 and then rather than add new controls you simply show one of the hidden ones and so on. Or you split your process in two so they do everything that doesn't involve file uploads, and then in a second stage do the file uploads. When answering a question please: • Read the question carefully.
• Understand that English isn't everyone's first language so be lenient of bad spelling and grammar. • If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome. • Don't tell someone to read the manual. Chances are they have and don't get it.
![Asp.net file upload control loses file on postback Asp.net file upload control loses file on postback](https://docs.microsoft.com/en-us/aspnet/web-forms/overview/data-access/working-with-binary-files/uploading-files-cs/_static/image7.png)
Provide an answer or move on to the next question. Let's work to help developers, not make them feel stupid.