用户
 找回密码
 入住 CI 中国社区
搜索
查看: 6781|回复: 5
收起左侧

[讨论/交流] 请高手帮忙解决一下文件上传类上传中文名称文件的问题

[复制链接]
发表于 2009-11-22 20:01:33 | 显示全部楼层 |阅读模式
我在上传非中文的文件时正常,但上传带有中文字符文件名的文件时,提示A problem was encountered while attempting to move the uploaded file to the final destination.很郁闷,找不到好的解决方案,请大家帮小弟一下,谢谢!

我的代码:
PHP复制代码
 
function upload() {
 
        $config['upload_path'] = './uploads/';
 
        $config['allowed_types'] = 'gif|jpg|png';
 
        /*
        A problem was encountered while attempting to move the uploaded file to the final destination.
 
        这个错误一般是上传文件的文件名不能是中文名,这个很郁闷!还未解决,大家可以用其它方法,重新改一下文件名就可以解决了!  
 
 
        */

 
        $config['max_size'] = '1024';
 
        $config['max_width']  = '1024';
 
        $config['max_height']  = '768';
 
        $this->load->library('upload', $config);
 
        if(!$this->upload->do_upload()) {
 
                echo $this->upload->display_errors();
 
        }
 
}
复制代码


此帖来自:http://www.php.la/bbs/thread-102-1-1.html

请高手解释一下出错的原因和解决方法!
 楼主| 发表于 2009-11-22 21:40:59 | 显示全部楼层
我想补充一下,如果不使用file_name和encrypt_name这两个参数,怎么实现中文名文件的上传呢?
发表于 2009-11-22 23:08:02 | 显示全部楼层
 楼主| 发表于 2009-11-23 09:09:40 | 显示全部楼层
你的帖子写的很不错,如果重命名的话,确实有些好处,但如果不重命名的话,怎么去修改呢?我试着在文件名加编码转换好像也不行啊!有没有方法上传中文图片不重命名呢?
发表于 2009-11-23 10:23:10 | 显示全部楼层
中文不能上传多半是编码问题,windows 是gb编码,linux 是 utf-8 编码,试着用 iconv 转码试试。
ci 172 的上传类已经支持改名上传了。
 楼主| 发表于 2009-11-23 11:46:24 | 显示全部楼层
暂时先改名上传吧,我继续研究一下,如果成功了,我把方法告诉大家! 谢谢xiaoniao 和 hex ,学习CI,支持CI!

本版积分规则