PDA

View Full Version : آپلود عکس



mnamazi
یک شنبه 03 آذر 1392, 15:57 عصر
با سلام و خسته نباشید .
صفحه ای دارم که داری دو فیلد با عنوان های نشانی لوگو ی سایت و نشانی فاوا آیکن،
حال میخواهم زمانی که کاربر این دو مقدار رد پر کرد دو فیل برایش عمل آپلود انجام دهد .
این نمونه کدی هست که من در کنترلر نوشتم، در صورت امکان آنرا ویرایش و به من بازگردانید .
با تشکر


function setting(){

$this->form_validation->set_rules('Title', 'عنوان سایت', 'trim|xss_clean');
$this->form_validation->set_rules('Des', 'توضیحات', 'trim|xss_clean');
$this->form_validation->set_rules('Keywords', 'کلمات کلیدی', 'trim|xss_clean');
$this->form_validation->set_rules('Favicon_Url', 'نشانی فاوا آیکن', 'trim|xss_clean');
$this->form_validation->set_rules('Logo_URL', 'نشانی لوگو ی سایت', 'trim|xss_clean');

if ($this->form_validation->run() == FALSE)
{
$data = $this->Blog_Config->getRow();
$data['content'] =$this->load->view('admin/config',$data,true);
$this->load->view('admin/main',$data);
}
else
{
$post = $this->input->post(null);
unset($post['confirm']);
foreach ($post as $key=>$value)
{
$row[$key]=$this->db->escape_str($value);
}

$config['upload_path'] = './uploads';
$config['allowed_types'] = 'gif|png|jpg';
$config['encrypt_name']=TRUE;
$config['remove_spaces']=TRUE;
$this->load->library('upload', $config);
$this->upload->initialize($config);

if ( ! $this->upload->do_upload('Logo_URL'))
{
$this->oi->add_error($this->upload->display_errors());

}
else
{
$up = $this->upload->data();
$row['Logo_URL'] = $up['file_name'];
}

$config['upload_path'] = './uploads';
$config['allowed_types'] = 'ico|gif|png';
$config['encrypt_name']=TRUE;
$config['remove_spaces']=TRUE;
$this->load->library('upload', $config);

if ( ! $this->upload->do_upload('Favicon_Url'))
{
$this->oi->add_error($this->upload->display_errors());

}
else
{
$up = $this->upload->data();
$row['Favicon_Url'] = $up['file_name'];
}



$this->Blog_Config->edit($row);
$this->oi->add_success('تنظیمات با موفقیت ویرایش شد ...');
$this->load->view('admin/main');

}

}