linlong3388 发表于 2012-6-18 11:31:55

請教一個圖片上傳的問題

請問CI 圖片上傳後的檔案名稱 ,是否可以自行訂義檔名呢?

謝謝! {:1_1:}

yunnysunny 发表于 2012-6-18 11:41:59

重名了呢?

linlong3388 发表于 2012-6-18 13:25:50

yunnysunny 发表于 2012-6-18 11:41 static/image/common/back.gif
重名了呢?

你好 , 我想以 "帳號+日期" 自行定義檔名{:1_1:}

niudongwei 发表于 2012-6-18 15:55:57

本帖最后由 niudongwei 于 2012-6-18 16:02 编辑

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


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

linlong3388 发表于 2012-6-19 08:33:36

niudongwei 发表于 2012-6-18 15:55 static/image/common/back.gif
http://codeigniter.com/user_guide/libraries/file_uploading.html

你好 ,file_name 似乎不允許變量命名 ,只能指定固定的常量值:L

lilv7214 发表于 2012-6-19 09:17:17

肯定可以啦,如果重名,后边加参数

niudongwei 发表于 2012-7-3 10:19:57

linlong3388 发表于 2012-6-19 08:33 static/image/common/back.gif
你好 ,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);

niudongwei 发表于 2012-7-3 10:20:37

linlong3388 发表于 2012-6-19 08:33 static/image/common/back.gif
你好 ,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);
页: [1]
查看完整版本: 請教一個圖片上傳的問題