0

File upload paths in MVC is null with jquery dialog

I have created a MVC application having two file uploads in view and created a POST action for this, with IEnumerable parameter to catch the files. When i am submitting the form the files are coming fine in the HttpPostedFileBase collection, but if the file upload controls are in a dialog(jquery pop up) the IEnumerable object is null. Please help me.

The following are the codes i have done.

View

 @using (Html.BeginForm("Details", "StudentRegistration", FormMethod.Post, new{ @class = "form ideal-form",enctype = "multipart/form-data"}))
    {
    <div id="divSignatureCapturePopUp" title="Capture Photo" style="display:none; float:left;">
    <input id="fileUploadSignature" type="file"  name ="fileUploadImages" style="width:200px"/>
    </div> 
    }

<input type="button" id="buttonCaptureSignature" name="CaptureSignature" class="ideal-button" value="Capture Signature" />

 <script type="text/javascript">
        $(document).ready(function () {
 $("#buttonCaptureSignature").click(function () {
                $("#divSignatureCapturePopUp").dialog({
                    width: 560,

                });                
            });
}
 </script>

controller

[HttpPost]
    public ActionResult Details(IEnumerable<HttpPostedFileBase> fileUploadImages)
    {

    }
Jameel Moideen
  • 7,542
  • 12
  • 51
  • 79
  • Compare html rendered in popup with that 'normal' maybe something is going wrong with the form (field names etc.). – Mariusz Jun 25 '13 at 12:20

1 Answers1

0

Seems like jqueryui widget move file input field outside form. Check posted data in chrome dev console in 'Network' tab and make sure that file data is in request.

If this suggestion is right you can modify form this way:

<div id="divSignatureCapturePopUp" title="Capture Photo" style="display:none; float:left;">
    @using (Html.BeginForm("Details", "StudentRegistration", FormMethod.Post, new{ @class = "form ideal-form",enctype = "multipart/form-data"}))
    {
         <input id="fileUploadSignature" type="file"  name ="fileUploadImages" style="width:200px"/>
         <input type="submit" value="rtwert" />
    }
</div> 

Оtherwise possible get files in other way:

[HttpPost]
public ActionResult Details()
{
    var files = Request.Files;
}
YD1m
  • 5,845
  • 2
  • 19
  • 23