zoukankan      html  css  js  c++  java
  • php结合jquery异步上传图片(ajaxSubmit)

    php结合jquery异步上传图片(ajaxSubmit)
    php结合jquery异步上传图片(ajaxSubmit),以下为提交页面代码:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Ajax异步上传图片</title>
    <script src="js/jquery-1.4.2.js" language="JavaScript" type="text/javascript"></script>
    <script src="js/jquery.form.js" language="JavaScript" type="text/javascript"></script>
    <script type="text/javascript">
    
    function sky_upfiles(){
        var messtxt;
     $("#sky_upform").ajaxSubmit({
                                    //dataType:'script',
                                    type:'post',
                                    url: "doupfiles.php",    
                                    beforeSubmit: function(){
                                        $("#sky_txt").html("图片上传中...");
                                    },
                                    success: function(data){        
                                        if(data=="1"){
                                        messtxt = "上传成功!";
                                        }else if(data=="-1"){
                                        messtxt = "文件超过规定大小!";
                                        }else if(data=="-2"){
                                        messtxt = "文件类型不符!";
                                        }else if(data=="-3"){
                                        messtxt = "移动文件出错!";
                                        }else{
                                        messtxt = "未知错误!";
                                        }
                                        $("#sky_txt").html(messtxt);                
                                        //$("#sky_txt").append(data);
                                    },
                                    resetForm: false,
                                    clearForm: false
                            });
                            //$("#upimgform").submit();
    }
    
            </script>
    </head>
    <body>
    <br />
    <fieldset style="97%">
      <legend>上传文件</legend>
        <form enctype="multipart/form-data" id="sky_upform" name="sky_upform" action="" method="post">
        <table width="100%" border="0" align="center" cellpadding="3" cellspacing="0">
          <tr>
            <td width="100" align="right" class="f-12"></td>
            <td class="f-12" align="left">
            <input name="upfile" id="upfile" maxlength="20" size="40" type="file" value="" /><input name="upmit" type="button" id="upmit" value="上传" onclick="sky_upfiles()"/>
            <font color="red" id="sky_txt"></font></td>
          </tr>       
        </form>
            
    </body>
    </html>

    jquery.form.js下载

    https://github.com/malsup/form

    下载源码:

    ajax_upfiles.rar

    转载:http://skyhome.cn/jquery/246.html

  • 相关阅读:
    孩孩,你妈正在生你。。。。。。。。
    想写点关于fpga以及软核nios2的入门文章
    源代码阅读工具SourceNavigator 在ubuntu 9.04下的安装与问题解决
    真理与知识
    需要思考的十对矛盾
    【Git】将已被推送到远程仓库的文件or文件夹,从远端删除
    明天是个大日子
    C# 编码规范
    Linux 登录 Mysql 数据库
    Linux Ubuntu 16.04 安装 .Net Core
  • 原文地址:https://www.cnblogs.com/wawahaha/p/4356670.html
Copyright © 2011-2022 走看看