• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
lacking unicode support for file uploading class?

#1
[eluser]Arjen van Bochoven[/eluser]
It probably is a php issue, but it would be nice if CI checked for unicode support or sanitizes the filename somewhat stricter.

When I upload a file with unicode chars in the filename, I get an error. Can anyone confirm this? I followed the guidelines in the User Guide which resulted in a working application.

I'm not to good in handling unicode, so I took the url_title function and extended the CI_Upload class with this:
Code:
<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');


class MY_Upload extends CI_Upload {

     /**
      * Extra filename cleaning for unicode chars etc.
      *
      * @return string
      * @author bochoven
      **/

    function clean_file_name($filename)
    {
        $replace = '_';
        $trans = array(
                        "\s+"                                => $replace,
                        "[^a-z0-9\.".$replace."]"                => '',
                        $replace."+"                        => $replace,
                        $replace."$"                        => '',
                        "^".$replace                        => ''
                       );

        $filename = strip_tags(strtolower($filename));

        foreach ($trans as $key => $val)
        {
            $filename = preg_replace("#".$key."#", $val, $filename);
        }

        return trim(stripslashes($filename));
        
    }
}

This strips the filename, and all is fine


Messages In This Thread
lacking unicode support for file uploading class? - by El Forum - 09-29-2007, 04:07 PM
lacking unicode support for file uploading class? - by El Forum - 09-30-2007, 03:39 AM
lacking unicode support for file uploading class? - by El Forum - 09-30-2007, 08:48 AM
lacking unicode support for file uploading class? - by El Forum - 09-30-2007, 10:09 AM
lacking unicode support for file uploading class? - by El Forum - 09-30-2007, 05:51 PM
lacking unicode support for file uploading class? - by El Forum - 10-01-2007, 07:41 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.