1

I'm working with the plupload plug-in in MVC 4 to upload images to the server, this plug-in gives a script which calls an action to apload images.So in this script I want to add code to pass some parameters in the URL but I didn't succeed. I looked for the solution and I found that there is a property in the script to add parameters:

multipart_params: { idflight: [parameter to add]},

so when I give an example of a value to idflight, it works and I find that the parameter passes. but when I try to get a value from a dropdownlist using the code

multipart_params: { idflight: $('#IDFLIGHT').val()},

it gives me the error Failed to load resource: the server responded with a status of 500 (Internal Server Error). Here is the view:

<div class="editor-label">
                            @Html.LabelFor(model => model.IDTYPE, "TYPES")
                        </div>
                        <div class="editor-field">
                            @Html.DropDownList("IDTYPE", String.Empty)
                            @Html.ValidationMessageFor(model => model.IDTYPE)
                        </div>

                        <div class="editor-label">
                            @Html.LabelFor(model => model.IDFLIGHT, "FLIGHTS")
                        </div>
                        <div class="editor-field">
                            **@Html.DropDownList("IDFLIGHT", String.Empty)**
                            @Html.ValidationMessageFor(model => model.IDFLIGHT)
                            @Html.ActionLink("Add New flight","Create","Flight",null,new{@style="font-size:16px;", @class="popup"})
                        </div>

I removed the form tag from it because I don't need it. And this is the script of the plug-in:

<script type="text/javascript">
    // Custom example logic

    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'pickfiles', // you can pass in id...
        unique_names:true,
        container: document.getElementById('container'), // ... or DOM Element itself
        **url: '../../../Image/Ajouter',**
        flash_swf_url: 'Scripts/Moxie.swf',
        silverlight_xap_url: 'Scripts/Moxie.xap',

        filters: {
            max_file_size: '10mb',
            mime_types: [
                { title: "Image files", extensions: "jpg,gif,png" },
                { title: "Zip files", extensions: "zip" }
            ]
        },
        **multipart_params: { idflight: $('#IDFLIGHT').val()},**

        init: {
            PostInit: function () {
                document.getElementById('filelist').innerHTML = '';

                document.getElementById('uploadfiles').onclick = function () {
                    uploader.start();
                    return false;
                };
            },

            FilesAdded: function (up, files) {
                plupload.each(files, function (file) {
                    document.getElementById('filelist').innerHTML += '<div id="' + file.id + '">' + file.name + ' (' + plupload.formatSize(file.size) + ') <b></b></div>';
                });
            },

            UploadProgress: function (up, file) {
                document.getElementById(file.id).getElementsByTagName('b')[0].innerHTML = '<span>' + file.percent + "%</span>";
            },

            Error: function (up, err) {
                document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
            }
        }
    });

    uploader.init();

Thank you in advance

Abdelouhab
  • 179
  • 3
  • 13

0 Answers0