I am working on a small method that saves uploaded images and records the images in a database.
public function setEventImages($event_id){
foreach($_FILES['event-images']['tmp_name'] as $tmp_name){
$imgName = $this->imgPath . $this->random_name . $_FILES['event-images']['name'];
move_uploaded_file($tmp_name, $imgName);
$stmt = $this->dbh->prepare("INSERT INTO adrenaline_junkies_uk_event_images (event_image_name, event_id) VALUES (?,?)");
$stmt->bindParam(1, $imgName, PARAM_STR);
$stmt->bindValue(2, $event_id, PARAM_INT);
$stmt->execute();
}
}
I was wondering if there was aHow can this be made more efficient way of doing this?