2011-02-24 42 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