views:

27

answers:

0

Hello guys

i want to upload photo to my application(asp.net mvc) using jquery Modal.

first i have created the div that will be displayed in the modal like the following :

<div id="dialog-form" title="Upload File">
    <p>
        <input type="file" id="fileUpload" name="fileUpload" />

     </p>
</div>

then when i press some Hyberlink the modal will appears and when i press ok i want to carry the photo to the action in controller for some processing ...

i dont know how to carry my photo to the server ...

the modal code looks like the following :

        $("#dialog-form").dialog({
            bgiframe: true,
            height: 200,
            modal: true,
            autoOpen: false,
            resizable: false,
            buttons: {
                Cancel: function () {
                    $(this).dialog('close');
                },
                Ok: function () {
                    $.ajax({
                        type: "POST",

                        url: '<%: Url.Action("Upload", "SomeController") %>',
                        success: function (result) {
                            if (result.Success == true) {
                                alert(result.Message);
                            }
                        }
                    });
                }
            }
        });

should i use the data in the $.ajax() .. but how ? and my controller expect from me nothing in signature... public JsonResult Upload() just like this

it looks for the uploaded files in Request.Files like :

foreach (string inputTagName in Request.Files) { some processing }

any help please ??