开发者

Create non English directories in PHP

I want to be able to create folders for the registered users under their names. Their info is stored in my db in Cyrillic characters and pulled from their when creating the folder. The thing is if the info is in English everything is ok, if in Cyrillic I get something like Кульчманова. Everything is set to utf-8. If I开发者_如何学Python set folder name to i.e 'фыва' it creates it no problem.

        $this->load->model('users_model');
    $i=$this->session->userdata('uid');
    $new_name=$this->input->post('doc_name');
    $folder=$this->users_model->getFullName($i); //$folder='фыва' works fine

    if(!is_dir("./uploads/".$folder)){
        mkdir("./uploads/".$folder , 0777);
    }
    $config['file_name'] = $new_name;
    $config['upload_path'] = './uploads/'.$folder.'/';

Will appreciate any help


I strongly recommend you to use only plain ASCII characters in directory names on servers, or even better: only numbers, lowercase letters, and underscore. Using special characters quite always brings trouble, and seems like you are already having some.

I suggest you to name the directory as the numeric user ID (they surely have one), padding with zeroes if you find it looks better (all the names have equal length).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜