模板页面添加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;
     }

最新文章

  1. 聚光灯下的熊猫TV技术架构演进
  2. 数据分析和R语言的那点事儿_1
  3. IOS 简单动画 首尾式动画
  4. HDU 3652:B-number(数位DP)
  5. (二)OJ的主要文件
  6. Codevs 1231 最优布线问题
  7. java 词法分析器
  8. AWR报告导出的过程报ORA-06550异常
  9. java.util.Map源码分析
  10. 02-测试、文件读写、xml解析
  11. 2014-08-29 Last Day
  12. Computer Graphics Thinking–texture tiling
  13. Http 信息头
  14. 简单方便又实用的在线作图工具:ProcessOn
  15. Android初级教程小案例之单选框RadioGroup与复选框CheckBox
  16. STL算法设计理念 - 预定义函数对象
  17. Python第七天 函数 函数参数 函数里的变量 函数返回值 多类型传值 函数递归调用 匿名函数 内置函数
  18. Hands-On Unity 2018 x 移动游戏开发教程
  19. Docker上运行MySQL服务
  20. [PHP]算法- 二叉树的深度的PHP实现

热门文章

  1. sharepoint 2010自定义访问日志列表设置移动终端否和客户端访问系统等计算列的公式
  2. LeetCode:罗马数字转整数【13】
  3. OpenGL纹理上下颠倒翻转的三种解决办法
  4. MODBUS协议 一种问答方式的通信协议
  5. [POI2008]账本BBB
  6. finally中的return
  7. 主攻ASP.NET.4.5.1 MVC5.0之重生:系统角色与权限(一)
  8. 防止iframe被别的网站引用
  9. 2018-2019-2 20165114《网络对抗技术》Exp6 信息收集与漏洞扫描
  10. 常见Web安全漏洞