2011-02-24 45 views
0

我在哪裏可以找到教程,其中的概念是上傳圖像,它保存圖像路徑與數據庫中的用戶ID和刪除功能。謝謝!Codeigniter Image上傳

這裏的概念形式

+--------+ +------------+ 
| avatar | |   | Browse 
+--------+ +------------+ 

+----------+ 
|   | name 
+----------+ 

+----------+ 
|   | age 
+----------+ 

+----------+ 
|   | address 
+----------+ 


+----------+ 
| Submit | 
+----------+ 

回答

1

這裏是一個沒有上載,數據庫和刪除應該很容易從那裏

http://net.tutsplus.com/tutorials/php/codeigniter-from-scratch-file-uploading-and-image-manipulation/

也檢討這個問題的笨頁

同樣的說明 Codeigniter: Image Upload

編輯----------------------------------------

我是假設您將中的圖像列出來編輯或刪除它們。我可以遠離你正在做的事情。我也假設你在使用「用戶ID」時也爲圖像本身分配了一個ID。

對於刪除我做這樣的事情

$this->table->set_heading('Date', 'Title', 'Delete', 'Update'); 
foreach($records as $row){ 
$row->title = ucwords($row->title); 

$this->table->add_row(
$row->date, 
anchor("main/blog_view/$row->id", $row->title),  
anchor("main/delete/$row->id", $row->id, array('onClick' => "return confirm('Are you  sure you want to delete?')")), 
anchor("main/fill_form/$row->id", $row->id) 
); 
} 
$table = $this->table->generate(); 

見第二錨?它拿起圖像的ID在DB和指向一個控制器功能:

function delete() 
{ 
    $this->is_logged_in(); 
    $this->post_model->delete_row(); 
    $this->maint(); 
} 

模型

function delete_row() 
{ 
    $this->db->where('id', $this->uri->segment(3)); 
    $this->db->delete('posts'); 
} 
+0

感謝您的答覆,我已經編寫上傳腳本,但這裏嗨爲m的問題不要你知道如何更新圖像?並用新位置替換位置中的圖像文件並刪除舊圖像? – Dave 2011-03-04 04:39:25

+0

請參閱上面編輯的回覆。我希望它有幫助。我可能不瞭解你在做什麼 – Brad 2011-03-06 05:10:28