嘿伙计们,我已经在我的mvc项目上安装了uploadify来处理一些文件上传,而且这部分工作非常好我只是想知道我需要添加到我的控制器操作中以获取对我的scriptData变量的访问权限从uploadify javascript传递
编辑以获得更多澄清:
我的uploadify脚本如下:
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();
});
});
我很好奇如何从我的控制器操作中访问这些数据
答案 0 :(得分:4)
通过接受我的控制器操作中的formcollection,我自己找到了一个通过它完成的答案,我可以从uploadify脚本中访问categoryID参数。
编辑某些代码:
[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";
}
答案 1 :(得分:0)
<script type="text/javascript">
$(function () {
$('#file_upload').uploadify({
'swf': "@Url.Content("~/Content/UploadifyContent/uploadify.swf")",
'cancelImg': "@Url.Content("~/Content/UploadifyContent/uploadify-cancel.png")",
'uploader': "@Url.Action("Upload", "Callout", new { @id = 5 })",
'scriptData': { 'id': $('#Job_Id').val() },
'onUploadSuccess': function (file, data, response) {
$("#uploaded").append("<img src='" + data + "' alt='Uploaded Image' />");
}
});
});
</script>
public ActionResult Upload(long id,HttpPostedFileBase FileData) {
}
用$('#/。blah')。val()或equiv
替换'5'