I am trying to build an ecommerce application . My task is to store an image which the user uploads
from his machine into the oracle database . I have created a blob datatype for the column which
stores the image . Now
View Code
@using (Html.BeginForm())
{
<div class="editor-field">
@Html.TextBoxFor(m => m.Description, new { id = "txtDescription" })
@Html.ValidationMessageFor(m => m.Description)
</div>
<div class="editor-label">
@Html.Label("Upload your picture");
</div>
<p>
<input type="file" id="imagesubmit" name="imagesubmit" value="Submit"
onclick="saveuserinfo();"/>
</p>
}
javascript code
function saveuserinfo()
{
var description = document.getElementById('txtDescription').value;
var imagefile = document.getElementById('imagesubmit');
$.ajax({
url: '@Url.Action("SaveuserInfo", "Welcome")',
data: { description: description,imagesubmit: imagesubmit},
type: 'POST',
success: function (data) {
}
});
}
Controller code
???
I need controller code in how to get the image from javascript and pass it to DB layer for inserting
into the database.
This is what i have been trying ..Is this the right approach to store the image
public ActionResult saveuserinfo(string description,)
{
return View("WelcomePage");
}
( I am stuck here with the code what datatype i have to use here to recieve the image and what
datatype i have to convert and send it to DB LAYER.