Cannot access closed file httppostedfile
Connect and share knowledge within a single location that is structured and easy to search. I have a code snippet which uploads an image. On uploading, it temporarily stores the file in a Session. Then on click of "Save", it saves the file in a database. There's no problem on my machine, but on the server, whenever I try to upload some files, and then click on "Save", it shows me an error "Closed file cannot be accessed".
On Googling it, I read here that this was due to large files being uploaded. I wanted to confirm, is the problem that I'm uploading large files?? Or could it be something else? Also, why am I not getting this on my machine and only on the server?? The first thing into fixing this issue is to get rid of the Sessions and temporarily store the uploaded file on the file system or if you are running in a web farm on a shared folder or if the files are not large enough you could even store them in the database.
So let's suppose that currently you are not running in a web farm and you have a single web server and that we could store the uploaded files in a temporary folder for which of course you will write a scheduled script that could run every night and delete older than X days files to avoid wasting disk space for nothing :.
Now if you want to handle large file uploads you should obviously make sure to adjust the proper settings in your web. By default you are limited to 4MB. Oh and while you are editing your web. NET Session:.
Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Why does "Cannot access closed file" error show up?
And why only on the server? Ask Question. Asked 9 years, 5 months ago. Active 9 years, 5 months ago. Viewed 2k times. Updated Dec pm RaisKazi. Add a Solution. Top Rated Most Recent. Accept Solution Reject Solution.
Posted Dec pm Monjurul Habib. This should help the OP, 5! Monjurul Habib Dec am. Hi, try this one: C. Posted Dec pm Jitendra Parida - Jeetu. Clean Solution and Build Again. It worked for me. Posted Aug pm tarunesh. Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account.
This email is in use. Do you need your password? Submit your solution! In the business bar at the top of the file, click Save As to save your file to your computer. You can also access these files by using these steps: Open the Office application you were using. Open a new file or any existing file. Click Info. Click Manage Versions. You will see the list of your unsaved files. Select the file and click Open.
Under Help, click Options. Click Save.
0コメント