zoukankan      html  css  js  c++  java
  • 无刷新上传图片信息

    <form id="formBug" name="formBug" method="post"
                      action="http://events.tiancity.com/cp/collect/api/collect_bug.php" enctype="multipart/form-data"
                      target="app_iframe" onsubmit="return validateForm(this);">
                    <table width="470" border="0">
                        <tr>
                            <td width="138"><b>*</b> 操 作 系 统 :</td>
                            <td width="322"><input type="text" class="txt01" name="os" request="true" maxlength="40"/></td>
                        </tr>
                        <tr>
                            <td><b>*</b> 操作系统版本:</td>
                            <td><input type="text" class="txt01" name="os_version" request="true" maxlength="10"/></td>
                        </tr>
                        <tr>
                            <td colspan="2"><b>*</b> 摘 要(标题):</td>
                        </tr>
                        <tr>
                            <td colspan="2"><textarea id="textarea" name="title" class="textarea01"
                                                      request="true" maxlength="40"></textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2"><b>*</b> 详 细 描 述 :</td>
                        </tr>
                        <tr>
                            <td colspan="2"><textarea id="textarea" name="description" class="textarea02"
                                                      request="true" maxlength="2000"></textarea></td>
                        </tr>
                        <tr>
                            <td colspan="2"><strong>上传文件(可选)(最大支持1024K)</strong>
                                <input type="file" class="up_img" value="浏览" size="15" name="file"/>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2"><b>* 为必填选项</b></td>
                        </tr>
                        <tr>
                            <td colspan="2"><input type="submit" value="" onfocus="this.blur()" class="btn01 input06"
                                                   name="">
                            </td>
                        </tr>
                    </table>
                    <iframe id="app_iframe" name="app_iframe" width="0" height="0"
                            scrolling="no" frameborder="0"></iframe>
                    <input type="hidden" name="submit_type" value="bug"/>
                </form>

    原理是把form提交到iframe,然后iframe提交到服务器.

    服务端处理完了以后可以使用JS调用客户端的回调函数

    /* 返回消息 */
    function showMessage ($msg)
    {
        echo "<script>parent.callback('{$msg}')</script>";
        exit();
    }
  • 相关阅读:
    Lock VS Monitor
    vue+element-ui路由配置相关
    数字与金额数字转换的正则表达式
    vue项目中多个入口的配置
    编写项目readme文件
    在vue中使用express-mock搭建mock服务
    编辑器——vscode
    【转】论前端的工程化
    vue学习
    node+express+http-proxy-middleware做代理
  • 原文地址:https://www.cnblogs.com/bossikill/p/3103129.html
Copyright © 2011-2022 走看看