internet-explorer - Codeigniter + Uploadify 用户在 IE 上传后自动注销

标签 internet-explorer codeigniter uploadify

我一直在使用 Codeigniter 和 Uploadify 制作照片库,它在 chrome 和 firefox 上运行良好。但是在 IE 上,当我上传图片时,文件上传到服务器上并创建了缩略图,但没有数据记录到数据库中。在 IE 上完成上传后,当我重新加载页面时,我总是自动注销并且必须重新登录。我正在使用 ag_auth 库。

Controller 中的上传方法:

    public function do_upload() {

    $this->load->library('upload');

    $gallery_title = $this->input->post('galleryTitle');
    $gallery_id = $this->input->post('galleryID');

    $folder_title = str_replace(' ', '_', $gallery_title);

    $image_upload_folder = FCPATH . '/uploads/image-gallery/' . $folder_title;

    if (!file_exists($image_upload_folder)) {
        mkdir($image_upload_folder, DIR_WRITE_MODE, true);
    }

    $this->upload_config = array('upload_path' => $image_upload_folder, 'allowed_types' => 'png|jpg|jpeg|bmp|tiff', 'max_size' => 2048, 'remove_space' => TRUE, 'encrypt_name' => FALSE,);

    $this->upload->initialize($this->upload_config);

    if (!$this->upload->do_upload()) {
        $upload_error = $this->upload->display_errors();
        echo json_encode($upload_error);
    } else {
        $thumb_upload_folder = $image_upload_folder . '/thumb';

        if (!file_exists($thumb_upload_folder)) {
            mkdir($thumb_upload_folder, DIR_WRITE_MODE, true);
        }

        $img = $this->upload->data();
        // create thumbnail
        $new_image = $thumb_upload_folder . '/thumb_' . $img['file_name'];

        $c_img_lib = array('image_library' => 'gd2', 'source_image' => $img['full_path'], 'maintain_ratio' => TRUE, 'width' => 120, 'height' => 120, 'new_image' => $new_image);

        $this->load->library('image_lib', $c_img_lib);
        $this->image_lib->resize();

        $file_info = $this->upload->data();
        echo json_encode($file_info);

        $root_path = str_replace("\\", "/", FCPATH);
        $path = str_replace($root_path, "", $file_info['file_path']);
        $url = $path . $file_info['file_name'];
        $thumb_url = $path . 'thumb/thumb_' . $file_info['file_name'];

        $this->load->database();

        $query = array('url' => $url, 'thumb_url' => $thumb_url, 'gallery_id' => $gallery_id);
        $this->db->insert('images', $query);

        $inserted_id = $this->db->insert_id();
        $query2 = array('order' => $inserted_id);

        $this->db->where('id', $inserted_id);
        $this->db->update('images', $query2);
    }
}

View 文件中的javascript:

        <script type="text/javascript">
        $(document).ready(function () {

            var base_url = '<?php echo base_url(); ?>';

            $('#upload-file').click(function (e) {
                e.preventDefault();
                $('#userfile').uploadify('upload', '*');
            });
            $('#userfile').uploadify({

                'debug':true,
                'auto':true,
                'swf': base_url + 'assets/js/jquery/uploadify_31/uploadify.swf',
                'uploader': base_url + 'glenn-admin/image_gallery/do_upload',
                'cancelImg': base_url + 'assets/javascript/jquery/uploadify_31/uploadify-cancel.png',
                'fileTypeExts':'*.jpg;*.bmp;*.png;*.tif',
                'fileTypeDesc':'Image Files (.jpg,.bmp,.png,.tif)',
                'fileSizeLimit':'2MB',
                'fileObjName':'userfile',
                'buttonText':'Upload Photos',
                'multi':true,
                'removeCompleted':true,
                'method': 'post',
                'formData': {'galleryTitle': '<?php echo $gallery_title ?>', 'galleryID': '<?php echo $gallery_id ?>'},
                'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                    alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
                },
                'queueID'  : 'image-queue',
                'onUploadProgress' : function(file, bytesUploaded, bytesTotal, totalBytesUploaded, totalBytesTotal) {
                    $('#progressbar').progressbar({
                        value: (totalBytesUploaded/totalBytesTotal)*100
                    });},
            });
</script>

这真的让我很为难。如果有人对此有解决方案,我将不胜感激。 附言:

好吧,我刚刚意识到问题出在我正在使用的身份验证库中,它是 AG_auth。它需要 Controller 扩展应用程序而不是 CI_Controller,当我删除它并将 Controller 扩展回 CI_Controller 时,它可以在 IE 上运行。但这确实不安全。所以问题是为什么当我使用 extend Aplication 但在 chrome 和 firefox 上工作时它不能与 IE 一起工作?

最佳答案

尽量不要比较用户代理 con config.php 并且不要在 cookie 名称上使用下划线。

关于internet-explorer - Codeigniter + Uploadify 用户在 IE 上传后自动注销,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13089042/

相关文章:

PHP:快速线程评论问题

javascript - 使用后退按钮后,Internet Explorer 显示文本节点的奇怪节点值

javascript - IE exec命令富文本编辑

javascript - Codeigniter - 如何使用 javascript 变量重定向到 Controller ?($this->load->view() 不工作)

mysql - 查询以获取每种类型的有限行

flash - 每个 Flash uploader 都会给出错误的进度值

javascript - 重定向到其他页面时 IE10 中的 Cookie 丢失

jquery - 尝试在选择框容器隐藏容器中使用滚动条

javascript - 返回 false 在 IE 中不起作用。

jquery - 上传错误#2038