[eluser]pickupman[/eluser]
Even though you are on windows, you still to check file permissions. This may not be the issue yet, but for 2000,Server 2k3/8, XP Pro, Vista, & 7 you have to give Full Access on your temporary upload folder. You can usually find this with phpinfo(); which will probably be something like c:\windows\tmp, c:\windows\temp, or c:\wamp\tmp(Wamp Server).
I did notice a few errors in the code. Your foreach loop is before the open form tag, but the form_close tag is after the foreach. In a sense you are opening the form multiple times but only closing it once.
Here is a working example of your code with a few changes (form validation).
Code:
//Controller
function index(){
//Set test data
$data['asset'] = (object)array('id'=>'10' , 'name' =>'John Doe', 'image' => 'home-banner.jpg');
$this->load->view('upload_view',$data);
}
function update_upload()
{
$this->load->library(array('upload','form_validation'));
$this->form_validation->set_rules('id', 'id', 'required|trim');
$this->form_validation->set_rules('name','name', 'required|trim');
$config['upload_path'] = './uploads/images';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '500';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->upload->initialize($config);
//Make sure form fields are completed
if($this->form_validation->run() == TRUE){
$img = $this->input->post('image');
//Check if file was uploaded
if (!$this->upload->do_upload('image'))
{
//Test data
$data['asset'] = (object)array('id'=>'10' , 'name' =>'John Doe', 'image' => 'home-banner.jpg');
$data['error'] = $this->upload->display_errors();
$this->load->view('upload_view',$data);
}
else
{
//Uploaded Completed
$data = $this->upload->data();
$name_file = "promo/".$data['file_name'];
$this->upload_model->update($name_file);
redirect('upload/view_upload', 'refresh');
}
}else{
//Test data
$data['asset'] = (object)array('id'=>'10' , 'name' =>'John Doe', 'image' => 'home-banner.jpg');
$this->load->view('upload_view', $data);
}
}
//View
<?
if(isset($error))
echo $error;
echo validation_errors();
$id = $asset->id;
$name = $asset->name;
$image = $asset->image;
echo form_open_multipart('upload/update_upload');
?>
<input type="hidden" name="id" value="<?=$id;?>"/>
<input type="text" name="name" size="20" value="<?=set_value('name',$name);?>"/><br/>
<img src="<?=base_url();?>uploads/<?=$image;?>"/><br/>
<input type="file" name="image"/><br/>
<input type="submit" value="Update" name="submit">
<?
echo form_close();
?>
I'm not sure if your foreach loop is supposed to be creating a upload form for each asset. If so, it would seem that the way you are redirecting you would only have one image update when someone submits the form.