CodeIgniter Forums

Full Version: orig_name wrong in upload->data() array
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]himself[/eluser]
Hi, couldn't find this anywhere so posting it here, presumably a bug

Using the upload class, and uploading files with speical characters (here Hebrew), the returned array is wrong, whereas the $_FILES['Filedata']['name'] is correct (so it's prob. not the server).

//uploading af file called: רפי גדרון.wmv

$data = $this->upload->data();
echo $data['orig_name']; // empty string
echo $_FILES['Filedata']['name']; "רפי גדרון.wmv"


Hope the hebrew chars makes it through the posting

cheers

El Forum

[eluser]pistolPete[/eluser]
I could partly reproduce your issue:
View upload.php:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;title&gt;upload&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
&lt;/head&gt;
&lt;body&gt;
<div>
&lt;form action="/test/upload" method="post" enctype="multipart/form-data" accept-charset="utf-8"&gt;
&lt;input type="file" name="userfile" /&gt;
&lt;input type="submit" name="upload" value="upload" /&gt;&lt;/form>
</div>
&lt;/body&gt;
&lt;/html&gt;

View upload2.php
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;title&gt;upload&lt;/title&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
&lt;/head&gt;
&lt;body&gt;
<div>
&lt;?php
echo '<pre>'.print_r($_FILES,TRUE).'</pre><br /><br />';
echo '<pre>'.print_r($this->upload->data(),TRUE).'</pre>';
?&gt;
</div>
&lt;/body&gt;
&lt;/html&gt;

Controller test.php:
Code:
&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Test extends Controller {
    
    public function __construct()
    {
        parent::Controller();
    }
    
    public function index()
    {
        $this->load->view('upload');
    }
    
    public function upload()
    {
        $this->load->library('upload');
        $config = array();
        $config['allowed_types'] = 'wmv';
        $config['upload_path'] = './';
        $this->upload->initialize($config);
        
        if(!$this->upload->do_upload('userfile'))
        {
            echo $this->upload->display_errors();
        }
        else
        {
            $this->load->view('upload2');
        }    
    }
}

/* End of file test.php */
/* Location: ./system/application/controllers/test.php */

Only if I use "charset=utf-8" in view upload.php, CodeIgniter gets the correct file name.

El Forum

[eluser]himself[/eluser]
Looks correct, I don't there is no html on my page so the only thing setting the charset is the settings from config/config.php (or is it config/database.php). Which as stated fails.