我正在尝试在页面中显示上传的图片。我在上传图片时使用了dropzone。
控制器:
public function do_uploadlogo($id){
$restologo=$_POST['restologo'];
$tempFile = $_FILES['file']['tmp_name'];
$fileName = $_FILES['file']['name'];
$targetPath = getcwd() . '/uploads/restaurants/logos/';
$targetFile = $targetPath . $fileName ;
$data = array(
'restologo' => 'uploads/restaurants/logos/'.$fileName
);
$this->load->database('findiningcebu');
$this->db->where('id', $id);
$this->db->update('restaurants',$data);
move_uploaded_file($tempFile, $targetFile);
}
public function addrestologolink($id){
$data = array(
"action" => base_url('/index.php/AdminController/do_uploadlogo/'.$id),
"data" => $this->db->get_where('restaurants',array('id'=>$id))
);
$this->load->view('admin/logo',$data);
}
查看
<div class="del" style="padding-left: 15px">Current Logo:</div>
<div class="del" style="padding-left: 15px"><img src="<?=base_url().$restologo?>" /></div>
请帮忙!
答案 0 :(得分:1)
使用此代码
<div class="del" style="padding-left: 15px">
<?php
echo'<img src="' . base_url().'uploads/restaurants/logos/' . $restologo . '">';
?>