如果截代码分享,请截出可以调试的整个部分!

来源:互联网 发布:财务管理数据库设计 编辑:程序博客网 时间:2024/06/08 02:47

鄙视网上某些Code大佬




I'm using the Bootstrap File Input plugin and I'm trying to get the images to the Controller but I'm not having any success. Has anyone implemented this in MVC that could give me some direction? I was successful in passing the contactId in the uploadExtraData property. If I comment that out and use the data property I receive an error message that a parameterless constructor for the method could not be found. That makes sense but I'm not sure how to pass the input array to the controller.

View Code

<div class="col-md-12 form-group">    <div class="editor-field">        <input id="input-702" name="kartik-input-702[]" type="file" multiple="true" class="file-loading">    </div></div><script type="text/javascript">    $(document).ready(function() {        $("#input-702").fileinput({            type: 'POST',            cache: false,            allowedFileExtensions: ['jpg', 'png', 'gif'],            allowedFileTypes: ['image'],            maxFileSize: 2000,            uploadUrl: '@Url.Action("ImageUpload", "Contact")',            maxFileCount: 2,            enctype: 'multipart/form-data',            overwriteInitial: true,            uploadExtraData: { 'request': document.getElementById('input-702').value, 'contactId' : document.getElementById('ContactID').value },            msgSizeTooLarge: "File {name} ({size} KB) exceeds maximum upload size of {maxSize} KB. Please Try again",            msgFilesTooMany: "Number of Files selected for upload ({n}) exceeds maximum allowed limit of {m}",            msgInvalidFileType: 'Invalid type for file "{name}". Only {types} files are supported.',            msgInvalidFileExtension: 'Invalid extension for file {name}. Only "{extensions} files are supported.',        });    });</script>
[HttpPost]public ActionResult ImageUpload(HttpRequest request, int contactId){    int contactID = (int)contactId;    return null;}

0 0