0

I am using asp.net fileupload control for multiple files uploading,I want to persist file upload control value. I got solution for Single file Here I am uploading multiple files to server, and checking each file for some special code which is stored in Database, If code is found in file then an email is sent to that user, If not then I am showing Modal Popup for selecting a User. When no code found,its showing modal popup but Removing the Selected File. I want that after Showing Modal It will still display the selected files. But I am uploading multiple files, so this solution not working for me,Below is my code

   HttpFileCollection hfcc;
    hfcc = Request.Files;
    for (int i = 0; i < hfcc.Count; i++)
    {
      HttpPostedFile hpf = hfcc[i];
if(codefound)
{
      hpf.SaveAs(//Folder Path and filename);
}
else
{
//Show Modal Popup
}
    }

How can I use Session in this scenario for maintaining value. I have tried making session like described in my previous question, but in that case i am not getting any file.

Community
  • 1
  • 1
Syed Salman Raza Zaidi
  • 2,172
  • 9
  • 42
  • 87
  • Are you talking about persisting the name of the file on the server side, or the client side? If it's the former, then look at using the `Session`... if it's the latter, then you're going to be out of luck, due to heavy browser security restrictions – freefaller Sep 12 '13 at 11:05
  • Sorry, I'm not sure I understand what your issue is. Unlike normal controls, file input controls will not "persist" the file location as it's a browser security issue... therefore it's unlikely that the user will be posting back the page the same files. So I'm having difficulty working out what purpose the persisting of the filename is supposed to acheive. Please can you give a more detailed explanation (by **editing** your question) to make it as clear as possible what you're trying to achieve here? – freefaller Sep 12 '13 at 11:10
  • If that is the formatting of your code in real-life (and not just a copy/paste error) then you're making life difficult for yourself right off the bat. – freefaller Sep 12 '13 at 11:26
  • From your new description, it sounds like you're asking for something which is really outside the scope of StackOverflow. Changing the processing you currently have for a single file upload into coping with multiple files that all could have differing results is going to be exceedingly complex. Therefore, I'm sorry, but I'm bowing out of this one. Good luck – freefaller Sep 12 '13 at 11:29
  • I think you're overthinking the asp.net web site too much into the realms of desktop applications... But still... @freefaller if you use javascript an dbig cookies, you can store files into them from an upload control. You can get the content of file controls with Javascript and upload them using XmlHttpRequest v2 – sinni800 Sep 12 '13 at 11:30
  • @freefaller No its my formatting in real Life, I format my code properly in VS – Syed Salman Raza Zaidi Sep 12 '13 at 11:31
  • @freefaller Its not beyong the scope of StackOverFlow, I have found solution for single file on this site – Syed Salman Raza Zaidi Sep 12 '13 at 11:32
  • Syed, in that case I'm sure somebody will come along and help - but I'm sorry, that will not be me. @sinni800, storing the file in a cookie? Seriously?? Ouch – freefaller Sep 12 '13 at 11:34
  • @freefaller Local storage. Still, there has to be a solution that doesn't need javascript shenanigans... – sinni800 Sep 12 '13 at 11:37
  • Fair enough @sinni800... I've not had chance to deal with HTML5, so bit out of my knowledge range. Right, I'm outta here – freefaller Sep 12 '13 at 11:38
  • @freefaller its ok bro – Syed Salman Raza Zaidi Sep 12 '13 at 11:48
  • maybe you could go for some components which are fit for this type of asynchronous multi files upload process like, for example, plupload ( www.plupload.com ) – jbl Sep 12 '13 at 12:10
  • I have tried uploadify,but no luck – Syed Salman Raza Zaidi Sep 12 '13 at 12:19

0 Answers0