@Pure.Krome's solution works if you have static values that don't change as users enter data into the page. I used that solution until I ran into the problem that the content of elements may have changed. Therefore I needed a solution that would modify the multipart_params only just before when the upload starts.
If multipart_params are passed to the contructor of Uploader() then using $('#foo').val()
uses the value of the element with id 'foo' that is has at that time. If element 'foo' is a form element then this may not be what you want.
Therefore, here is an alternative. For the constructor you may want to pass the following parameters:
var uploader = new plupload.Uploader({
// other params
multipart: true
});
Then just before you start the upload you need to set the multipart_params. For example you might have a button somewhere on your page. For that button you have a JavaScript handler that starts the upload. The resulting handler including setting the multipart_params then might look as follows:
$('#uploadfiles').click(function (e) {
uploader.settings.multipart_params = { param1: document.getElementById("id1").value, param2: document.getElementById("id2").value };
uploader.start();
e.preventDefault();
});
Note that you can change the name 'param1' to something more meaningful e.g. 'Title'. You probably also will have an id more meaningful than 'id' for your input elements. On the controller side (I'm using MVC 4), the implementation then may look something like:
public ActionResult Upload(string name = "", int chunk = 0, int chunks = 0, string param1 = "", string param2 = "") {
// ... your code here ...
}
To stay with the example: If you changed the parameter name from 'param1' to 'title' then of course the parameter name for the action also needs to be changed from 'param1' to 'title' accordingly. The resulting code, also showing where you get the file stream from looks then as follows:
public ActionResult Upload(string name = "", int chunk = 0, int chunks = 0, string title = "", string param2 = "") {
// ... your code here ...
System.Web.HttpPostedFileBase fileUpload = Request.Files[0];
// ... and more of your code here ...
}