Welcome Guest, Not a member yet? Register   Sign In
Problem with display_errors
#11

[eluser]jacobc[/eluser]
Sorry I'm really not thinking... use

Code:
foreach($_FILES as $key => $value) {
    $this->upload->initialize($config);
    if ( ! $this->upload->do_upload($key)) {
        $data['error'] = $this->upload->display_errors();

        $this->load->view('propreg/f_propreg3_multifileupload_v1', $data); //Upload Form

    }
    else {
        $this->load->model('Process_image');

        $this->Process_image->process_pic();

    }
}

And just do
Code:
<?php echo $error ?>
in the view.


Of course it really seems like a waste just using a view for that... so you could either create an array of all the errors which is how I was originally thinking...

Then loop through them in the view...

Or else, why use a view at all? just echo it from the controller.
#12

[eluser]xwero[/eluser]
[quote author="jacobc" date="1236864032"]
Code:
foreach($_FILES as $key => $value) {
    $this->upload->initialize($config);
    if ( ! $this->upload->do_upload($key)) {
        $data['error'] = $this->upload->display_errors();

        $this->load->view('propreg/f_propreg3_multifileupload_v1', $data); //Upload Form

    }
    else {
        $this->load->model('Process_image');

        $this->Process_image->process_pic();

    }
}
[/quote]
Displaying a view in a loop and reloading the model is not a good idea.
Code:
$errors = array();
$this->load->model('Process_image');

foreach($_FILES as $key => $value) {
    $this->upload->initialize($config);
    if ( ! $this->upload->do_upload($key))
    {
        $errors[] = $this->upload->display_errors();
    }
    else
   {
        $this->Process_image->process_pic($this->upload->data());
   }
}

$data['message'] = (count($errors) > 0)?implode('',$errors):'All files are uploaded.';

$this->load->view('propreg/f_propreg3_multifileupload_v1', $data); //Upload Form
#13

[eluser]jacobc[/eluser]
That is what I was getting at originally...
#14

[eluser]xwero[/eluser]
Sorry i didn't read further. I just saw code that set off alarm bells in my head Smile
#15

[eluser]tim1965[/eluser]
jacobc

Many thanks i now have it echoing correctly. However i still seem to be getting an undefined variable error on $error (now set to your last post). Any ideas why ??
#16

[eluser]jacobc[/eluser]
I can't see why $error would be undefined...

It would be saying it is undefined in your view, but it should be passed in with the $data variable.
Quite unusual.

There should be no case currently where that view would be called without $error defined. :S

What xwero posted is much better code... So you get all the errors and process the images... then you can send all the errors to a view and loop through them...
#17

[eluser]tim1965[/eluser]
xwero and jacobc

Thanks for pointing out my errors. Yes its very strange the undefined variable. I now get it on $messages. I will keep on beavering away this end, just wondering if i was missing something obvious. Many thanks for your help.




Theme © iAndrew 2016 - Forum software by © MyBB