new code below. I use this oop PHP it was working I added this here because I deleted my older version of the question that was bad. if someone needs this kinda code is usable.
public function set_file($file) {
if(empty($file) || !$file || !is_array($file)) {
$this->errors[] = "There was no file uploaded here";
return false;
}elseif($file['error'] !=0) {
$this->errors[] = $this->upload_errors_array[$file['error']];
return false;
} else {
$this->user_image = basename($file['name']);
$this->tmp_path = $file['tmp_name'];
$this->type = $file['type'];
$this->size = $file['size'];
}
}
public function move_image(){
$target_path = SITE_ROOT.DS. 'admin' . DS . $this->upload_directory . DS . $this->user_image;
return move_uploaded_file($this->tmp_path, $target_path);
}
2
Answers
Try specify file’s input name attribute as array:
and then you must refactor code work with $_FILES. This values will be arrays:
you can use this foreach loop too or anyone who needs.