码迷,mamicode.com
首页 > 其他好文 > 详细

Ajax 图片上传

时间:2014-07-26 03:33:47      阅读:211      评论:0      收藏:0      [点我收藏+]

标签:java   os   io   for   art   re   c   cti   

废话不说;直接上代码:

你懂得:

,导入js .

<script type="text/javascript"
    src="${pageContext.request.contextPath}/cmsui/javascript/jquery.js"></script>
<script type="text/javascript"
    src="${pageContext.request.contextPath}/cmsui/ui/jquery.form.js"></script>
<form id="imgfilesupload" action="file_imgFileUpload.action"
                    method="post" enctype="multipart/form-data" isclick="0">
                    <input type="file" name="file" dataType="Require" msg="请选择视频封面图片" />
                    <button id="imgsSubmit" type="button" class="button">上传</button>
                </form>
       $("#imgsSubmit").click(function() {
            imgsupload_video();
        });

        function imgsupload_video() {
            var tf = Validator.Validate($("#imgfilesupload")[0], 2);
            if (tf != true) {
                return;
            }
            
             $(this).attr("disabled","disabled");
            $("#imgfilesupload").ajaxSubmit({
                success : function(result) {
                    var num = result.replace(/<[^>]+>/g, "");
                    var msg = "成功!";
                    var isclick = "1";
                    if (num == "0") {
                        msg = "失败!";
                        isclick = "0";
                    } else if (num == "-1") {
                        msg = "图片格式不正确!";
                        isclick = "0";
                    }
                    top.Dialog.alerts("提示", msg, function() {
                        $("#imgurl").val(num);
                        $("#videoimg").attr("src",num);
                        $("#imgfilesupload").attr("isclick", isclick);
                    });
                }

            });
        }


Ajax 图片上传,布布扣,bubuko.com

Ajax 图片上传

标签:java   os   io   for   art   re   c   cti   

原文地址:http://my.oschina.net/yangcaoling/blog/294939

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!