<?php include '/etc/rr_inventory.php';

$id = $_POST['id'];

$target = "uploads/" . basename($_FILES["photo"]["name"]);

if (move_uploaded_file($_FILES["photo"]["tmp_name"], $target)) {

    $stmt = $mysqli->prepare("
        INSERT INTO photos (rolling_stock_id, file_path)
        VALUES (?,?)
    ");
    $stmt->bind_param("is", $id, $target);
    $stmt->execute();
}

header("Location: edit.php?id=$id");
