Shubham Agrawal
Shubham Agrawal

Reputation: 1300

How to redirect to base_url after zip download in codeigniter

I am using zip library for adding files to zip and download them, but once the download is complete I am unable to redirect it to main page. How can I achieve that. Please provide code for that.

This is my success function:

function success(){
    // Get the transaction data
    $paypalInfo = $this->input->get();
    $data['question_id'] = $paypalInfo['item_number']; 
    $question_id = $data['question_id'];
    redirect(base_url('Accounting/download/').$question_id, 'refresh');         
}

This refresh is not working.

This Accounting/download is my method to download the zip file.

Upvotes: 0

Views: 186

Answers (1)

omerimzali
omerimzali

Reputation: 41

You can try to open .zip file on a new tab, and after that you can redirect your main page to base url

<script>

    window.onload = function(){
         window.open(<?php echo base_url('Accounting/download/').$question_id; ?>, "_blank"); // will open new tab on window.onload
    }
</script>

Upvotes: 1

Related Questions