模板页面添加ifreme
<div style=' display: none;' >
     <iframe name ="uploadResponse_attachment" id= "uploadResponse_attachment"></iframe >
    <form id ="uploadForm_attachment" action= "<?php echo site_url('logistics/upload_chartering_attachment') ?>" target= "uploadResponse_attachment" method ="post" enctype= "multipart/form-data">
     <input type ="hidden" name="<?php echo $this->security->get_csrf_token_name(); ?>" value= "<?php echo $this->security->get_csrf_hash(); ?>" />
    </form >
</div>
 
对应js页面添加
//上传租船附件
function upload_attachment_chartering()
{
     $('#attachment_img_notice').show();
    var file = document.getElementById( "chartering_attachment");
    var uploadFormElement = document.getElementById("uploadForm_attachment" );
   
    uploadFormElement .appendChild(file);
    document.getElementById("attachment_img_div").innerHTML = '<a href="javascript:void(0)" class="btn_blue_26"><span>上传</span></a><input type="file" onchange="upload_attachment_chartering()" name="chartering_attachment" multiple="multiple" id="chartering_attachment">';
 
    //提交图片数据
    uploadFormElement .submit();
    uploadFormElement.removeChild( uploadFormElement.chartering_attachment);
}
 
//上传成功回掉
function upload_attachment_chartering_callback(file_path)
{
    $(".attachment_show_img").attr( 'src',file_path);
    $('#attachment_image').val(file_path);
    $('#attachment_img_notice').hide();
    $('.attachment_error').html( '');
    $('.attachment_error').hide();
}
 
//上传失败回掉
function upload_attachment_chartering_fail_callback(fail_remind)
{
     $(".attachment_show_img").attr( 'src', '/images/11.gif');
     $('#attachment_image').val( '');
     $('#attachment_img_notice').show();
    $('.attachment_error').html(fail_remind);
    $('.attachment_error').show();
}
 
public function _upload_chartering_attachment_post()
     {
           $data = upload_member_voucher('chartering_attachment' );
            if($data[ 'succ'] == 1){
                $file_path = $data[ 'file_path'];
                 echo "<script type='text/javascript'>parent.upload_attachment_chartering_callback('$file_path ')</script>";
           } else{
                $fail_reason = $data[ 'fail_reason'];
                 echo "<script type='text/javascript'>parent.upload_attachment_chartering_fail_callback('".$fail_reason. "')</script>";
           }
     }
 
function upload_member_voucher($form_file_id = '' ) {
            if (!$form_file_id) {
                 return;
           }
           $ci = &get_instance();
           $cert_dir = $ci-> config->item( 'cert_path') . '/';
           $day_dir = date( 'Ym');
           $physics_path = FCPATH . '..' . $cert_dir . $day_dir;
            if (!is_dir($physics_path)) {
                mkdir($physics_path, 0755);
           }
           $config[ 'upload_path'] = $physics_path; //文件上传目录
 
           $config[ 'encrypt_name'] = true;
           $config[ 'allowed_types'] = "gif|jpg|png|tif"; //文件类型
           $config[ 'max_size'] = "1048"; //最大上传大小
           $ci-> load->library( "upload", $config);
 
            if ($ci-> upload->do_upload($form_file_id)) { //表单中name="userfile"
                $data = $ci-> upload->data(); //返回上传图片的信息
                $res[ 'succ'] = 1;
                $res[ 'file_path'] = $cert_dir . $day_dir . '/' . $data['file_name'];
           } else{
                $res[ 'succ'] = 0;
                $res[ 'fail_reason'] = $ci->upload->display_errors();
           }
            return $res;
     }

通过ifreme实现文件上传的更多相关文章

  1. jquery.uploadify文件上传组件

    1.jquery.uploadify简介 在ASP.NET中上传的控件有很多,比如.NET自带的FileUpload,以及SWFUpload,Uploadify等等,尤其后面两个控件的用户体验比较好, ...

  2. 11、Struts2 的文件上传和下载

    文件上传 表单准备 要想使用 HTML 表单上传一个或多个文件 须把 HTML 表单的 enctype 属性设置为 multipart/form-data 须把 HTML 表单的method 属性设置 ...

  3. Java FtpClient 实现文件上传服务

    一.Ubuntu 安装 Vsftpd 服务 1.安装 sudo apt-get install vsftpd 2.添加用户(uftp) sudo useradd -d /home/uftp -s /b ...

  4. 小兔Java教程 - 三分钟学会Java文件上传

    今天群里正好有人问起了Java文件上传的事情,本来这是Java里面的知识点,而我目前最主要的精力还是放在了JS的部分.不过反正也不麻烦,我就专门开一贴来聊聊Java文件上传的基本实现方法吧. 话不多说 ...

  5. ,net core mvc 文件上传

    工作用到文件上传的功能,在这个分享下 ~~ Controller: public class PictureController : Controller { private IHostingEnvi ...

  6. Web开发安全之文件上传安全

    很长一段时间像我这种菜鸡搞一个网站第一时间反应就是找上传,找上传.借此机会把文件上传的安全问题总结一下. 首先看一下DVWA给出的Impossible级别的完整代码: <?php if( iss ...

  7. AutoIt实现Webdriver自动化测试文件上传

    在运用WebDriver进行自动化测试时,由于WebDriver自身的限制,对于上传文件时Windows弹出的文件选择窗口无法控制,通过在网上查找资料锁定使用AutoIt来控制文件上传窗口. Auto ...

  8. Struts的文件上传下载

    Struts的文件上传下载 1.文件上传 Struts2的文件上传也是使用fileUpload的组件,这个组默认是集合在框架里面的.且是使用拦截器:<interceptor name=" ...

  9. .JavaWeb文件上传和FileUpload组件使用

    .JavaWeb文件上传 1.自定义上传 文件上传时的表单设计要符合文件提交的方式: 1.提交方式:post 2.表单中有文件上传的表单项:<input type="file" ...

随机推荐

  1. C语言预处理命令的使用

    cppreference.com -> 预处理命令 -> 详细说明 预处理命令 #,## # 和 ## 操作符是和#define宏使用的. 使用# 使在#后的首个参数返回为一个带引号的字符 ...

  2. 【转】Python爬虫(3)_Beautifulsoup模块

    一 介绍 Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库.它能够通过你喜欢的转换器实现惯用的文档导航,查找,修改文档的方式.Beautiful Soup会帮你 ...

  3. $Android自定义控件风格的方法

    EditText在获取焦点后默认的边框都是黄色的,这可能和我在开发的应用的主题颜色不匹配,那怎么办呢?——用自定义的控件风格,比如说我想让EditText在获取焦点时候边框变成蓝色的,而失去焦点后边框 ...

  4. first application

    <!DOCTYPE html> <html> <head> <title>Create a Map</title> <meta htt ...

  5. ubuntu里设置从串口登录

    1) Create a file called /etc/init/ttyS0.conf containing the following: # ttySAC0 - getty # # This se ...

  6. [NOI2008]奥运物流

    题目 洛谷 BZOJ 做法 单环有向图毒瘤题 不考虑环和改变后继:\(\sum\limits{i=1}^n C_i\cdot K^{dep(i)}\) 考虑环无穷等比求极m:\(R(1)=\sum\l ...

  7. console、JSON兼容问题

    console在ie8上面竟然有兼容问题,JSON.stringify()在ie10下竟然会报错,再页面上引用一个json2.js能解决此问题.

  8. goseq

    goseq是一个R包,用于寻找GO terms,即基因富集分析. GO terms是标准化描述基因或基因产物的词汇,包括三方面,cellular component,molecular funcito ...

  9. 编写自已的第一个MapReduce程序

    从进入系统学习到现在,貌似我们还没有真正开始动手写程序,估计有些立志成为Hadoop攻城狮的小伙伴们已经有些急了.环境已经搭好,小讲也有些按捺不住了.今天,小讲就和大家一起来动手编写我们的第一个Map ...

  10. Qt发布程序

    一.作用 将Qt软件打包发布成绿色exe,在任意非Qt环境下运行 二.找到我们软件所依赖动态库 使用Qt的windeployqt.exe(在Qt安装目录的bin下面找)--! 1.新建文件夹,在里面放 ...