I have a ViewModel:
public HttpPostedFileBase File { get; set; }
public string Notes { get; set; }
In the Create
view, I have an <input type="file" name="file" />
that binds the HttpPostedFile
to the model. So far, so good.
My problem begins when I try to develop the "Edit" action with their respective view.
I haven't problems at all to show the editor field for the string property Notes
, that part is easy.
However, how do I show the <input type="file" name="file" />
with the actual value in the Edit
view? How do I to bind a byte array to the File
property of the ViewModel? Is that the correct way? Is there another better solution? I'm stranded with this and would appreciate your help.
You can't. An <input type="file" />
is not made for editing files, just for uploading them.
If you just want to be able to delete the file in the edit view try this (just an example):
DeleteFile
to the edit view modelDeleteFile
is set to true and if so, find and delete the file attached to that record you are editingAnd you could rename File
to UploadedFile
(so its a bit clearer). But thats up to you of course.