I have the following in my View
<div name="image-upload-section" class="control-label">
@using (Ajax.BeginForm("UploadAdditionalImage", "Image", "UploadAdditionalImage", ajaxOptions, new { enctype = "multipart/form-data" })) {
<label>Upload Image:</label>
<input name="files" type="file" id="uploadAdditionalImage" onchange="PreviewAdditional();" />
<input type="submit" value="Upload Image" class="btn btn-default" />}
<img id="uploadAdditionalImagePreview" style="max-height:200px;" />
</div>
<div name="imageGallery" id="imageGallery"></div>
<script>
function PreviewAdditional() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadAdditionalImage").files[0]);
oFReader.onload = function(oFREvent) {
document.getElementById("uploadAdditionalImagePreview").src = oFREvent.target.result;
};
}
</script>
When I include:
<script type="text/javascript" src="/Scripts/jquery.unobtrusive-ajax.js"></script>
My controller receives files as null, but without unobtrusive-ajax it works fine, as you would have guessed it returns an obtrusive partial view.
I've tried OnSuccess and Update in AjaxOptions, but they do not seem to work.
Are there any workarounds for this? I probably missed something due to lack of experience with jQuery and JavaScript.
I have two forms on a single view and the one above should upload files and return a list objects(URL, Id, etc.).