CodeIgniter Forums
Upload class upload path error msg appears twice - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Upload class upload path error msg appears twice (/showthread.php?tid=7103)



Upload class upload path error msg appears twice - El Forum - 03-25-2008

[eluser]tomcode[/eluser]
When uploading an image without having the correct path set I get the error message twice.

I'm working under Apache 2, PHP5

Code:
upload_data Array
(
    [error] => <p>The upload path does not appear to be valid.</p><p>The upload path does not appear to be valid.</p>

)

Edit : Both CI 1.6.1 and SVN version of today


Upload class upload path error msg appears twice - El Forum - 03-25-2008

[eluser]Référencement Google[/eluser]
I confirm this problem too, looks like a real bug.


Upload class upload path error msg appears twice - El Forum - 03-25-2008

[eluser]scottzirkel[/eluser]
Quick fix:

In your libraries directory, open Upload.php and change the display_errors function to this:

Code:
function display_errors($open = '<p>', $close = '</p>')
    {
        $str = '';
        foreach(array_unique($this->error_msg) as $val)
        {
            $str .= $open.$val.$close;
        }
    
        return $str;
    }



Upload class upload path error msg appears twice - El Forum - 03-25-2008

[eluser]tomcode[/eluser]
@wonderdog : Looks nice.


Upload class upload path error msg appears twice - El Forum - 03-27-2008

[eluser]tomcode[/eluser]
wonderdog's quick fix does it for me.


Upload class upload path error msg appears twice - El Forum - 03-27-2008

[eluser]GSV Sleeper Service[/eluser]
another possible fix. in the do_upload method (line #144) you'll see

Code:
// Is the upload path valid?
        if ( ! $this->validate_upload_path())
        {
            $this->set_error('upload_no_filepath');
            return FALSE;
        }

you could just change this to
Code:
// Is the upload path valid?
if ( ! $this->validate_upload_path())
{
    return FALSE;
}

as validate_upload_path sets the error