Uploadify在MVC中使用方法案例(一个视图多次上传单张图片)

Controller 中代码和 上一节文章(http://www.cnblogs.com/yechangzhong-826217795/p/3785842.html )一样

视图中代码如下:

<script type="text/javascript">
    $(function () {
        $(".uploadpic").each(function (i) {
            $('#uploadify' + i).uploadify({
                'buttonText': '上传文件',
                'swf': '@Url.Content("~/Themes/Scripts/Uploadify/uploadify.swf")',
                'uploader': '/waste/user/upload',
                'removeCompleted': true,
                'checkExisting': true,
                'fileTypeDesc': '文件类型',
                'fileTypeExts': '*.jpg;*.png;*gif',
                'fileSizeLimit': '1024KB',
                'auto': true,
                'width': 65,
                'height': 20,
                'multi': false,
                'queueSizeLimit': 1,      //允许上传几个文件?
                'queueID': 'fileQueue' + i,  //指定上传进度条在哪里显示
                //上传成功后的回调函数
                'onUploadSuccess': function (file, data, response) {
                    var obj = jQuery.parseJSON(data); //把返回的Json序列转化为obj对象
                    if (obj.Success) {
                        $('#input' + i).val(obj.FilePath);
                        $('#upsucc' + i).text('上传成功!');
                    }
                    else
                        alert(obj.Message);
                }
            });
        });

 

    <li>
                <table>
                    <tr>
                        <td>@Html.LabelFor(m => m.EIAReport) </td>
                        <td><div id="uploadify0" class="uploadpic"></div> </td>
                        <td><div id="fileQueue0" class="fileQueue"></div></td>
                        <td>@Html.ValidationMessageFor(m => m.EIAReport) <span id="upsucc0" style="color:red"></span></td>
                    </tr>
                </table>
                @Html.TextBoxFor(m => m.EIAReport, new { id = "input0", @style = "display:none" })
            </li>
            <li>
                <table>
                    <tr>
                        <td>@Html.LabelFor(m => m.BusinessLicense)</td>
                        <td><span id="uploadify1" class="uploadpic"></span> </td>
                        <td><div id="fileQueue1" class="fileQueue"></div></td>
                        <td>@Html.ValidationMessageFor(m => m.BusinessLicense) <span id="upsucc1" style="color:red"></span></td>
                    </tr>
                </table>
                @Html.TextBoxFor(m => m.BusinessLicense, new { id = "input1", @style = "display:none" })
            </li>
            <li>
                <table>
                    <tr>
                        <td>@Html.LabelFor(m => m.OrganizationCertificate)</td>
                        <td><span id="uploadify2" class="uploadpic"></span></td>
                        <td><div id="fileQueue2" class="fileQueue"></div></td>
                        <td>@Html.ValidationMessageFor(m => m.OrganizationCertificate) <span id="upsucc2" style="color:red"></span></td>
                    </tr>
                </table>
                @Html.TextBoxFor(m => m.OrganizationCertificate, new { id = "input2", @style = "display:none" })
            </li>

 

转载于:https://www.cnblogs.com/yechangzhong-826217795/p/3785895.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值