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

[HELP] 請教一個圖片上傳的問題

[复制链接]
发表于 2012-6-18 11:31:55 | 显示全部楼层 |阅读模式
請問  CI 圖片上傳後的檔案名稱 ,是否可以自行訂義檔名呢?

謝謝!
发表于 2012-6-18 11:41:59 | 显示全部楼层
重名了呢?
 楼主| 发表于 2012-6-18 13:25:50 | 显示全部楼层
yunnysunny 发表于 2012-6-18 11:41
重名了呢?

你好 , 我想以 "帳號+日期" 自行定義檔名
发表于 2012-6-18 15:55:57 | 显示全部楼层
本帖最后由 niudongwei 于 2012-6-18 16:02 编辑

http://codeigniter.com/user_guide/libraries/file_uploading.html

file_nameNoneDesired file name
If set CodeIgniter will rename the uploaded file to this name. The extension provided in the file name must also be an allowed file type.

 楼主| 发表于 2012-6-19 08:33:36 | 显示全部楼层
niudongwei 发表于 2012-6-18 15:55
http://codeigniter.com/user_guide/libraries/file_uploading.html

你好 ,file_name 似乎不允許變量命名 ,只能指定固定的常量值
发表于 2012-6-19 09:17:17 | 显示全部楼层
肯定可以啦,如果重名,后边加参数
发表于 2012-7-3 10:19:57 | 显示全部楼层
linlong3388 发表于 2012-6-19 08:33
你好 ,file_name 似乎不允許變量命名 ,只能指定固定的常量值

       $config = array(
            'upload_path' => 'e:/web/root/',
            'allowed_types' => 'jpg|jpeg|png|gif',
            'max_size' => 3072,
            'encrypt_name' => false
            );
       $config['file_name'] = time().'file';
      
$this->load->library('upload', $config);
发表于 2012-7-3 10:20:37 | 显示全部楼层
linlong3388 发表于 2012-6-19 08:33
你好 ,file_name 似乎不允許變量命名 ,只能指定固定的常量值

当然可以用变量的

       $config = array(
            'upload_path' => 'e:/web/root/',
            'allowed_types' => 'jpg|jpeg|png|gif',
            'max_size' => 3072,
            'encrypt_name' => false
            );
       $config['file_name'] = time().'file';
      
       $this->load->library('upload', $config);

本版积分规则