Skip to main content

c# - store HttpContext.Current.Request.Files in session variable -


I want to store the user-uploaded files in the session variable, so that I can access it from any page in my project I can use it. .i The retrieving file statement is from:

  httpFileCollection upload = HttpContext.Current.Request.Files;  

How can I store and retrieve it in session frequency ??

Thanks in advance

The way you are in session and from Store any and any other objects:

  // store session ["uploaded files"] = upload; // Retrieve (session ["uploaded files"]! = Null) {// attempt-grab blocks left for brevity Please apply yourself HttpFileCollection myUploads = (HttpFileCollection) session ["UploadedFiles"] ; // Do something with HttpFileCollection (like Save) // Remove the object from the session after recovering it. Session.Remove ("UploadedFiles"); }  

The knowledge of storing this object in the session is quite controversial and I do not recommend it.

To dispute (mention your previous question) that the HttpFileCollection variable can not be stored in session status, I deny that as I have already been able to do this once Once you have achieved the object in a variable, you can save it, however you want it.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -