Welcome Guest, Not a member yet? Register   Sign In
Redirection in controllers
#1

[eluser]deadfrog[/eluser]
Hi all. I have a controller with a function called do_upload which manages file uploads. It either succeeds or fails, and this works fine.

The form action is:

Code:
<?php echo form_open_multipart('upload/do_upload'); ?>

And if the upload fails, it all works as I want except the URL changes to this:

Code:
http://xxx:8888/upload/do_upload

I call my index function and pass in the error array:

Code:
$this->index($errors);

but ideally I'd like the URL to revert back to what it was before. Is this easy/possible?
#2

[eluser]SeanJA[/eluser]
In your do_upload controller function (or where ever the form goes to) you should probably have something like:

Code:
if (upload_failure){
    redirect($uploadpage_url);
}

There is more in the user guide I am sure, but this is what I did on mine:

Code:
function results(){
...
if (empty($searchterm) && $funding == "Select" && $job_type == "Select" && $city == "Select"){
            redirect('multiple/search/error/empty');
        }
...
}

Hope that helps




Theme © iAndrew 2016 - Forum software by © MyBB