<?php
namespace App\Controllers;
use App\Core\Controller;
use App\Core\Database;

class AdminGalleyController extends Controller
{
    public function upload(): void
    {
        $db = Database::getInstance();
        $id = $_POST['submission_id'];

        $file = $_FILES['pdf']['name'];
        $path = "uploads/galleys/".$file;

        move_uploaded_file($_FILES['pdf']['tmp_name'],$path);

        $db->prepare("INSERT INTO galleys(submission_id,file_path) VALUES (?,?)")
           ->execute([$id,$path]);

        header("Location: ".base_path('admin/production'));
        exit;
    }
}
