I am creating a stock form which includes up to 20 image files. When uploading the images to the server i need to change the name and also insert them into a database so that it
Don't harcode the indices of the upload array. Instead build you array dynamically:
$i = 0;
$uploads = array();
if(move_uploaded_file($file_tmp, $file_destination)) {
$uploaded[$position] = $file_destination;
$image = ($i==0) ? 'image' : 'image_'.$i;
$uploads[$image]=$uploaded;
$i++;
}
Then use it:
$insert = DB::getInstance()->insert('stock', $uploads);