I am using jquery form to upload an image without page refresh. Following is the html markup:
<a href="javascript:void(0);" onclick="UpdateImage();">
<img src="@_fullImgPath" name="img-uploader" alt="" title="" /></a>
@using (Html.BeginForm("UpdateImage", "Profile", FormMethod.Post, new { id = "img-file-upload-form", @class = "form", autocomplete = "off", enctype = "multipart/form-data" }))
{
@Html.Hidden("UpdateImageId")
<input type="file" name="file" id="file" />
}
<script language="javascript" type="text/javascript">
$(function () {
$("#img-file-upload-form").ajaxForm({
iframe: true,
dataType: "json",
beforeSubmit: function () {
},
success: function (result) {
alert('done');
},
error: function (xhr, textStatus, errorThrown) {
alert('error');
}
});
$("#file").change(function () {
$("#img-file-upload-form").submit();
});
});
function UpdateImage(id) {
$("input[id=file]").click();
}
</script>
This works fine in Firefox and Chrome, but in IE 8 and 9, it throws access denied error. Is there any fix for this? Or any alternative to upload the image without page refresh?