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??
EDIT: By the way, the error showed up when the file size > 80kb
Code on Uploading file:
public ActionResult StoreLogoInSession(HttpPostedFileBase file, int assetID)
{
string filename = null;
if (ValidateOnUpload(file))
{
Session.Add("TempLogo", file);
filename = file.FileName;
Session.Add("filename", filename);
}
return RedirectToAction("Edit", new { id = assetID });
}
Code on Saving (this is when the error occurs):
public ActionResult SaveLogo(LogoModel m, int assetID)
{
HttpPostedFileBase file = (HttpPostedFileBase)Session["TempLogo"];
var logoModel = new LogoModel();
var asset = this.GenerateAssetForUploadFile(file, (int)m.Asset.AccountID, m.Asset.TextContents, m.Asset.AssetName);
this.LogoManagementFacade.SaveLogo(asset);
logoModel.Asset = asset;
this.LogoModelList.Add(logoModel);
}