... I am doing something very wrong, I have a simple page with file input control and a submit button is. I am trying to get the new "File" action result which was released with MVC RC ...
All, I have to do this when the submit button is clicked, the selected file is databases It all works fine ...
Then, after refresh the page, I want an image which resulted in the image being uploaded. The issue is that the image is not being rendered ... I get a broken image ...
This is the part that is receiving the file and sending it back in the view ...
var a = helper Service. GetAttachmentById (ID, subscription provider, security ticket); If (A == blank) {See refresh (new image placeholder view data (new {id = id}); } View return (new image placeholder view data (new {id = aid, image = a, file content = file (a.data, a. Content type)}));
Then I have an image tag in the view ...
I have also tried ...
& lt; Img src = "& lt;% = Model.FileContent%>" / & Gt;
thoughts .. ??
File Result gives ASCII or binary content of the file when you say do the following:
& lt; Img src = "& lt;% = Model.FileContent.FileContents%>" / & Gt;
You are trying to push binary image data into the src
attribute, this will never work, because src
There should be a URL or a path to an image.
What you want, and in this case, there are several ways to get the most correct solution, to create a new controller that returns the binary data like you, and then you will be on your new controller Set the src
attribute to be the path to correct the action. Ex:
& lt; Img src = "/ image / results / 12345" /> Public class ImageController: Controller {public action result result (result result) {/ ... stuff here ... returns file (..); }}
Note that the name I chose is not the best, but it fulfills its purpose as an example. Hope this was useful.
Comments
Post a Comment