thinkphp 关于iframe一次提交完成所有操作
一、上传操作html界面,upload.html
<import type='css' file="admin.css.common" />
<import type='css' file="admin.css.main" />
<form action="{:U('Public/upload_post')}" style="height:40px;" enctype="multipart/form-data" method="post" >
<input type="file" name="photo" class="input-text lh30" size="10" />
</form>
二、页面引用upload页面
<input type="hidden" name="picurl" id="picurl" value="" />
<iframe width="100%" id="uploadframe" name="uploadframe" frameborder="0" height="40" src="{:U('Public/upload')}"></iframe>
三、点击提交
<input type="submit" onclick="return jc();" name="button" class="btn btn82 btn_save2" value="保存">
<input type="resit" name="button" class="btn btn82 btn_res" value="重置">
四、js提交操作,实现upload页面上传提交操作
function jc(){
if($(window.frames["uploadframe"].document).contents().find("input").val()){
$(window.frames["uploadframe"].document).contents().find("form").submit();
return false;
}
}
五、上传控制器处理。当上传成功后,js使父框架原表单提交。
public function upload_post(){
$upload = new \Think\Upload();// 实例化上传类
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
$upload->rootPath = './Uploads/'; // 设置附件上传根目录
$upload->savePath = ''; // 设置附件上传(子)目录
// 上传文件
$info = $upload->upload();
if(!$info) {// 上传错误提示错误信息
$this->error($upload->getError());
}else{// 上传成功
echo '<script>parent.document.getElementById("picurl").value="'. $info["photo"]['savepath'].$info["photo"]['savename'].'";
parent.document.getElementById("myFrom").submit(); </script>';
// $this->success('上传成功!');
}
}
thinkphp 关于iframe一次提交完成所有操作的更多相关文章
- 修改bug 提交出错:操作失败: 无法更改关系,因为一个或多个外键属性不可以为 null
提交出错:操作失败: 无法更改关系,因为一个或多个外键属性不可以为 null.对关系作出更改后,会将相关的外键属性设置为 null 值.如果外键不支持 null 值,则必须定义新的关系,必须向外键属性 ...
- jsp 嵌套iframe 从iframe中表单提交并传值到外层
今天因需求迭代 更改元来代码 遇到了这么个问题 就是想在 iframe中提交后进行整个页面的跳转 并把iframe中的值传到外层jsp 大概就是这个样子 外层 a.jsp <div id=&qu ...
- iframe 加form提交数据
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 调试一个Ext打开的window窗口内嵌Iframe的form提交问题
一个奇怪的问题是:潜逃在iframe里的页面单独提交都是正常,放到iframe里面通过js调用在parent页面.提交总是被莫名其妙的杀掉. 确定js简单无错之后,继续看parent的处理逻辑,有这么 ...
- 对thinkphp静态模板表单提交的理解
看表单的提交<form action="{$Think.const.__SELF__}" method="post">...</form&g ...
- thinkphp数据库添加表单提交的数据
$data['catename'] = I('catename'); 获取表单的数据 $cate=D('cate'); 实例化cat ...
- thinkphp 点击某个class提交post值,返回回来用一个弹窗插件,提示返回来要说的话
下一篇文章有讲到弹窗插件的怎么使用,自写教程 如果能帮到你,给点个赞鼓励一下 <============= 控制器 =================> public function ...
- fastadmin iframe 表单提交之后跳转
controller 对应的那个js文件中添加: define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function($, und ...
- JDBC自动提交和批处理操作
今天用JDBC与数据库进行交互的时候,报错如下: *************************************************************************** ...
随机推荐
- C# 键值对类相关
一 C# 键值对类有以下类: ① IDictionary<string, Object> idc = new Dictionary<string, object>(); ...
- SpringHttpInvoker解析3-客户端实现
主要的配置文件 <bean id="httpInvokerUserService" class="org.springframework.remoting.http ...
- js常用函数陆续总结
1.each() 方法规定为每个匹配元素规定运行的函数. $.each(data,function(index,item){ sb.append(item.answerNum); } $(" ...
- Glow Android 优化实践
了解 Glow 的朋友应该知道,我们主营四款 App,分别是Eve.Glow.Nuture和Baby.作为创业公司,我们的四款 App 都处于高速开发中,平均每个 Android App 由两人负责开 ...
- EBay .Net SDK Api 实践
1.请求流程介绍 提供SOA地址:https://api.ebay.com/wsapi WSDL生成的代码在WebService.cs文件当中. ApiCall封装了所有的RPC, ...
- 自定义UICollectionViewLayout之瀑布流
目标效果 因为系统给我们提供的 UICollectionViewFlowLayout 布局类不能实现瀑布流的效果,如果我们想实现 瀑布流 的效果,需要自定义一个 UICollectionViewLay ...
- BZOJ3424 : Poi2013 Multidrink
详细做法以及证明请看论文<Hamiltonian paths in the square of a tree>. 首先将1到n的路径提取出来,作为主干. 定义毛毛虫为去掉叶子之后只有一条单 ...
- 【HDU3652】B-number 数位DP
B-number Problem Description A wqb-number, or B-number for short, is a non-negative integer whose de ...
- html5调用手机相机并压缩、上传
近日刚做的一个功能,要在app里使用内嵌页面进行图像的上传.从功能上看,原生的实现应该是最好的.毕竟页面上所有的东西都隔着一个浏览器,所有的实现都要依赖浏览器提供的接口,不同的浏览器对接口的实现又有差 ...
- Android 定位地理坐标体系
参考: 中国特色 火星坐标 iOS 火星坐标相关整理及解决方案汇总 百度地图坐标转换API 地球坐标系 (WGS-84) 到火星坐标系 (GCJ-02)百度坐标系 (BD-09) 的转换算法 火星坐标 ...