Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access scriptData from uploadify in asp.net MVC controller?

I've got uploadify handling some file uploads on my mvc project and that part is working very nicely. I just want to know what I will need to add to my controller action to get access to scriptData variables that I am passing from the uploadify javascript.

EDIT for some more clarification:

My uploadify script is as follows:

var fileCategoryID;
$(document).ready(function() {
$('#uploadify').uploadify({
    'uploader': '../../scripts/uploadify.swf',
    'cancelImg': '../../content/images/cancel.png', 
    'script': '../../' + $('#Controller').val() + '/FileSave/' + $('#OrderID').val(),
    'folder': 'Uploads',
    'multi': true, 
    'auto': false,
    'queueSizeLimit': 5,
    'queueID': 'fileQueue',
    'displayData': 'speed',
    'fileExt': '*.pdf',
    'fileDesc': 'PDF',
    'sizeLimit': '5242880',
    'scriptData': { 'categoryID': fileCategoryID }
});
$('#fileCategory').change(function() {
    fileCategoryID = $('#fileCategory').val();
});
});

I am curious how I can access this data from within my controller action

like image 443
Jimmy Avatar asked Oct 22 '09 18:10

Jimmy


1 Answers

Found an answer working through it on my own, by accepting a formcollection in my controller action i can access the categoryID parameter from the uploadify script.

EDIT for some code:

 [AcceptVerbs(HttpVerbs.Post)]
 public string FileSave(long id, HttpPostedFileBase FileData, FormCollection forms)
 {
     long catID = Int64.Parse(forms.Get("CategoryID"));

     //do something with files

     return "Upload Successful";
 }
like image 157
Jimmy Avatar answered Oct 15 '22 19:10

Jimmy