Welcome Guest, Not a member yet? Register   Sign In
Image Edit Problem
#1

[eluser]hema[/eluser]
Hi All,


I am struck with edit form of image. I am having 4 image buttons in upload form where i can upload all images and when i am unable to edit the uploaded images. I am using this function to upload images.

For example in my edit form i don't want to edit first image and if i edit 3rd or 4th image. this function is uploading in the place of first image . How can i get rid of this.



function multiple_upload($upload_dir = 'images/', $config = array())
{
$CI =& get_instance();
$files = array();


if(empty($config))
{
$config['upload_path'] = realpath($upload_dir);
$config['allowed_types'] = 'gif|jpg|jpeg|jpe|png';
$config['max_size'] = '2048';
$config['max_width'] = '400';
$config['max_height'] = '250';
}

$CI->load->library('upload', $config);

$errors = FALSE;

foreach($_FILES as $key => $value)
{

//print_r($_FILES);
if( ! empty($value['name']))
{
if( ! $CI->upload->do_upload($key))
{
$data['upload_message'] = $CI->upload->display_errors(ERR_OPEN, ERR_CLOSE); // ERR_OPEN and ERR_CLOSE are error delimiters defined in a config file
$CI->load->vars($data);
$errors = TRUE;
}
else
{
// Build a file array from all uploaded files
$files[] = $CI->upload->data();

}
}
}


echo "<br> the value of img1 is $img1 <br> and $img2 <br> and $img3 <br> and $img4 <br>and $img5 <br>";



// There was errors, we have to delete the uploaded files
if($errors)
{
foreach($files as $key => $file)
{
@unlink($file['full_path']);
}
}
elseif(empty($files) AND empty($data['upload_message'])Wink
{
$CI->lang->load('upload');
$data['upload_message'] = ERR_OPEN.$CI->lang->line('upload_no_file_selected').ERR_CLOSE;
$CI->load->vars($data);
}
else
{
return $files;

}



}




Theme © iAndrew 2016 - Forum software by © MyBB