2

I Try to integrate my Codeigniter web with uploadify. its work fine in Chrome and even IE, but getting HTTP 302 error when I run my web in Mozilla firefox. and sometimes its show "IO Error" too, I read this post: 302 and IO uploadify error, but still doesnt have idea what I must to do. maybe more detail/clear guide would be help.

this is my uploadify config in view:

$('#shopfile').uploadify({
            'debug':false,
            'auto':true,
            'swf': '<?= base_url(); ?>file/lib/uploadify/uploadify.swf',
            'uploader': '<?= base_url(); ?>my_shop/upload_shopheader',
            'cancelImg': '<?= base_url(); ?>file/lib/uploadify/uploadify-cancel.png',
            'fileTypeExts':'*.jpg;*.jpeg;*.png;',
            'fileTypeDesc':'Image Files (.jpg,.jpeg,.png)',
            'fileSizeLimit':'2MB',
            'fileObjName':'shopfile',
            'buttonText':'Select File',
            'multi':false,
            'removeCompleted':false,
            'onUploadError' : function(file, errorCode, errorMsg, errorString) {
                alert('The file ' + file.name + ' could not be uploaded: ' + errorString);
                $( ".uploadMessageStr" ).html('<div class="alert alert-danger">The file ' + file.name + ' could not be uploaded: ' + errorString + '</div>');
            },
            'onUploadSuccess' : function(file, data, response){
                //some statement..
            }
        });

and this is my controller / uploader function code :

public function upload_shopheader(){
    if (empty($_FILES['shopfile']['name'])) redirect('my_shop/profile');

    $config = $this->avatarUploadConfig();
    $this->upload->initialize($config);
    $data = array();

    if (!$this->upload->do_upload('shopfile')) { 
        //if upload failed...
        $upload_error = $this->upload->display_errors();
        $data['message'] = "<div class='alert alert-danger'>Upload Failed. ".$upload_error."</div>";
    } 
    else { 
        //if upload success...
    }

    echo json_encode($data);
}

Thanks before.

1 Answer 1

2

SOLVED with add session id manually through uploadify.

adding this to uploadify config in view:

'formData' : {'SESSION_ID' : '<?= $this->session->userdata('session_id'); ?>'},

and add this code in beginning of controller function:

//check session..
    $sess_id = $this->input->post('SESSION_ID');
    if(!isset($sess_id)){
        redirect('to_some/page');
    }
    else{
        $this->session->set_userdata(array('session_id' => $sess_id));
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.