Hi - This problem has been driving me absolutely crazy, but I have a workaround to the problem of the control posting the previously selected file on subsequent post backs. What seems to be happening when you clear the previously selected files and the user selects a new file is BOTH are being sent to the server. To deal with this, I see if there are multiple files in the HttpPostedFileBase, and if so, I just use the last one.
Obviously, this workaround presents a few problems
- . Unnecessary data is being posted to the server
- It will not work if you are looking to take advantage of the multi-image upload functionality.
Here is what I did on my controller. I hope someone benefits from this.
public JsonResult UploadImage(string catalogItemId, string action, IEnumerable<HttpPostedFileBase> imageFiles)
var files = imageFiles.ToList();
if ( files.Count() > 1 )
correctFile = files.LastOrDefault();
correctFile = files.FirstOrDefault();